ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hide worksheets at startup (https://www.excelbanter.com/excel-programming/339754-hide-worksheets-startup.html)

Sandy

Hide worksheets at startup
 
Hello -

I need to hide sheets when my app first begins (all except one). What is
the best way to do this? I don't want to hide each one individually.

Also, I'm assuming I would put the code in ThisWorkbook.

Any help is appreciated!
--
Sandy

Chip Pearson

Hide worksheets at startup
 
Sandy,

Put the following code in the ThisWorkbook code module:

Private Sub Workbook_Open()
Dim WS As Worksheet
For Each WS In Worksheets
If WS.Name < "The One You Don't Want To Hide" Then
WS.Visible = xlSheetHidden
End If
Next WS
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Sandy" wrote in message
...
Hello -

I need to hide sheets when my app first begins (all except
one). What is
the best way to do this? I don't want to hide each one
individually.

Also, I'm assuming I would put the code in ThisWorkbook.

Any help is appreciated!
--
Sandy




Peter Noneley

Hide worksheets at startup
 
Sandy,

If you are hiding to prevent people seeing your data, maybe you should
save the workbook with all but one sheet hidden, and then unhide the
other sheets when the workbook is opened. This way, if a user disables
macros they will only see the one sheet.

You can use Chips code and change one line:

WS.Visible = true

Thats all, Good Luck!

Peter Noneley
Cardiff
Wales
UK

Chip Pearson wrote:
Sandy,

Put the following code in the ThisWorkbook code module:

Private Sub Workbook_Open()
Dim WS As Worksheet
For Each WS In Worksheets
If WS.Name < "The One You Don't Want To Hide" Then
WS.Visible = xlSheetHidden
End If
Next WS
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Sandy" wrote in message
...
Hello -

I need to hide sheets when my app first begins (all except
one). What is
the best way to do this? I don't want to hide each one
individually.

Also, I'm assuming I would put the code in ThisWorkbook.

Any help is appreciated!
--
Sandy



Ron de Bruin

Hide worksheets at startup
 
Hi Peter

Good to see you in the newsgroup
I hope you are OK

If you have a update of your "Excel Function Dictionary" or if
your site is working again let me know and I change the link.

http://www.rondebruin.nl/id.htm
Bottom of the page

Good night


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Peter Noneley" wrote in message oups.com...
Sandy,

If you are hiding to prevent people seeing your data, maybe you should
save the workbook with all but one sheet hidden, and then unhide the
other sheets when the workbook is opened. This way, if a user disables
macros they will only see the one sheet.

You can use Chips code and change one line:

WS.Visible = true

Thats all, Good Luck!

Peter Noneley
Cardiff
Wales
UK

Chip Pearson wrote:
Sandy,

Put the following code in the ThisWorkbook code module:

Private Sub Workbook_Open()
Dim WS As Worksheet
For Each WS In Worksheets
If WS.Name < "The One You Don't Want To Hide" Then
WS.Visible = xlSheetHidden
End If
Next WS
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Sandy" wrote in message
...
Hello -

I need to hide sheets when my app first begins (all except
one). What is
the best way to do this? I don't want to hide each one
individually.

Also, I'm assuming I would put the code in ThisWorkbook.

Any help is appreciated!
--
Sandy





Peter Noneley

Hide worksheets at startup
 
HI Ron,

Yes, I've been away for a while, but hoping to get back into the swing
of things!

Peter.



All times are GMT +1. The time now is 04:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com