Unhide multiple sheets at the same time

  • Thread starter Thread starter alish
  • Start date Start date
A

alish

All,

I need your help: I have a lot of Exls work book I need to unhide sheets in.
Each work book contains 15 sheets out of which 14 of them must be deleted and
all of the 14 are hidded sheets. How do I select all hidden sheets and delete
at the same time? Thanks you'll.
 
Shouldn't need to unhide first

Sub deletehiddensheets()
Application.DisplayAlerts = False
For i = Sheets.Count To 2 Step -1
If Sheets(i).Visible = False Then Sheets(i).Delete
Next i
End Sub
 
You don't have to unhide them in order to delete them, nor do you have to
select them either. This code will delete **all** hidden sheets and it will
do so **without** warning the user that the sheets being deleted might have
information on them and it will **not** ask the user to confirm the
deletions. Place the following code in a Module (click Insert/Module from
the VBA editor's menu bar and copy/paste into the code window that
appears)...

Sub DeleteHiddenSheets()
Dim WS As Worksheet
Application.DisplayAlerts = False
For Each WS In Worksheets
If WS.Visible = xlSheetHidden Then WS.Delete
Next
Application.DisplayAlerts = True
End Sub

If you wanted to let the warning prompts show through (one for each sheet
being deleted), remove the two Application.DisplayAlert statements.

WARNING: The deletions are permanent and cannot be undone. Translation...
test the code out on a workbook with no real data in it!

Rick
 
Thank you guys, it worked, but, Rick how do I get it to ask me what sheets to
delete? Thanks again.
 
Back
Top