ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hiding and Unhiding work sheets (https://www.excelbanter.com/excel-programming/283039-hiding-unhiding-work-sheets.html)

Paul B[_6_]

Hiding and Unhiding work sheets
 
Frank, here is one way,

Sub HideAll()
'will hide all sheets except sheet 1
For Each sh In Worksheets
If Not sh.Name = "Sheet1" Then
sh.Visible = xlHidden
End If
Next sh
End Sub


--
Paul B
Always backup your data before trying something new
Using Excel 2000 & 97
Please post any response to the newsgroups so others can benefit from it
** remove news from my email address to reply by email **
"Frank" wrote in message
...
I know by using the following code I can un-hide all work
sheets,

Sub sheetunhide()
For Each sh In Sheets
sh.Visible = True
Next sh
End Sub

I also want to be able to hide all sheets except a
specific one, does anyone know how to do this.

Thanks




Frank[_19_]

Hiding and Unhiding work sheets
 
I know by using the following code I can un-hide all work
sheets,

Sub sheetunhide()
For Each sh In Sheets
sh.Visible = True
Next sh
End Sub

I also want to be able to hide all sheets except a
specific one, does anyone know how to do this.

Thanks

Ron de Bruin

Hiding and Unhiding work sheets
 
Try this Frank

It will hide all sheets except Sheet1

Sub sheetunhide()
For Each sh In ThisWorkbook.Sheets
If sh.Name < "Sheet1" Then
sh.Visible = False
End If
Next sh
End Sub


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



"Frank" wrote in message ...
I know by using the following code I can un-hide all work
sheets,

Sub sheetunhide()
For Each sh In Sheets
sh.Visible = True
Next sh
End Sub

I also want to be able to hide all sheets except a
specific one, does anyone know how to do this.

Thanks




Trevor Shuttleworth

Hiding and Unhiding work sheets
 
Frank

untested, but something like:

Sub SheetHide()
For Each sh In Sheets
If sh.name < "xxxx" Then
sh.Visible = False
End If
Next sh
End Sub

Bear in mind that at least one sheet must be visible.

Regards

Trevor


"Frank" wrote in message
...
I know by using the following code I can un-hide all work
sheets,

Sub sheetunhide()
For Each sh In Sheets
sh.Visible = True
Next sh
End Sub

I also want to be able to hide all sheets except a
specific one, does anyone know how to do this.

Thanks





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

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