Hiding and Unhiding work sheets

  • Thread starter Thread starter Paul B
  • Start date Start date
P

Paul B

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 **
 
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
 
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
 
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
 
Back
Top