Hiding and Unhiding work sheets

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 **
 
F

Frank

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
 
R

Ron de Bruin

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
 
T

Trevor Shuttleworth

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top