ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hide/Unhide worksheets help (https://www.excelbanter.com/excel-programming/273242-hide-unhide-worksheets-help.html)

Jeremy Gollehon[_2_]

Hide/Unhide worksheets help
 
Using OfficeXP.
In a fresh workbook from the immediate window...

This works.
Worksheets(Array("Sheet1", "Sheet2")).Visible = xlSheetHidden

This:
Worksheets(Array("Sheet1", "Sheet2")).Visible = xlSheetVisible

gives the following error

Run-time error '1004':
Unable to set the Visible property of the Sheets class

This seems like an easy one, but I haven't been able to find an answer.

Thanks,
-Jeremy



Ron de Bruin

Hide/Unhide worksheets help
 
You can use this Jeremy

Dim sh As Worksheet
For Each sh In Sheets(Array("Sheet1", "Sheet2"))
sh.Visible = True
Next


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Jeremy Gollehon" wrote in message ...
Using OfficeXP.
In a fresh workbook from the immediate window...

This works.
Worksheets(Array("Sheet1", "Sheet2")).Visible = xlSheetHidden

This:
Worksheets(Array("Sheet1", "Sheet2")).Visible = xlSheetVisible

gives the following error

Run-time error '1004':
Unable to set the Visible property of the Sheets class

This seems like an easy one, but I haven't been able to find an answer.

Thanks,
-Jeremy





Jeremy Gollehon[_2_]

Hide/Unhide worksheets help
 
Thanks for the reply Ron.

So that means there's no way to do it without a loop?
My actual array is much larger.
I wonder why the hide works, but the unhide doesn't?

-Jeremy

Ron de Bruin wrote:
You can use this Jeremy

Dim sh As Worksheet
For Each sh In Sheets(Array("Sheet1", "Sheet2"))
sh.Visible = True
Next



"Jeremy Gollehon" wrote in message
...
Using OfficeXP.
In a fresh workbook from the immediate window...

This works.
Worksheets(Array("Sheet1", "Sheet2")).Visible = xlSheetHidden

This:
Worksheets(Array("Sheet1", "Sheet2")).Visible = xlSheetVisible

gives the following error

Run-time error '1004':
Unable to set the Visible property of the Sheets class

This seems like an easy one, but I haven't been able to find an
answer.

Thanks,
-Jeremy





All times are GMT +1. The time now is 05:41 AM.

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