Unhide hidden sheets

M

Minos

I found that to unhide hidden sheets in Excel you have to do one by one or
sheet by sheet. Is there a way by which I can a select more than one sheet to
unhide and unhide them simultaneously instead of doing it one by one?


Minos
 
D

Dave Peterson

You always have to have at least one sheet visible, but you could use code like
this:

Option Explicit
Sub UnhideAll()
Dim wks As Object
For Each wks In ActiveWorkbook.Sheets
wks.Visible = xlSheetVisible
Next wks
End Sub

Sub HideSelected()
Dim wks As Object
On Error Resume Next
For Each wks In ActiveWindow.SelectedSheets
wks.Visible = xlSheetHidden
If Err.Number <> 0 Then
MsgBox wks.Name & " was not hidden"
Err.Clear
End If
Next wks
On Error GoTo 0
End Sub

The second procedure hides the sheets that are grouped--click on the first sheet
tab and ctrl-click on subsequent.
 
Top