View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
lee lee is offline
external usenet poster
 
Posts: 184
Default Delete Hidden Sheets

Below is a free macro widely available on numerous sites to delete hidden
sheets in a workbook:

Sub Delete_Hidden_Sheets()

' Remove hidden sheets from your document
i = 1
While i <= Worksheets.Count
If Not Worksheets(i).Visible Then
Worksheets(i).Delete
Else
i = i + 1
End If
Wend
End Sub

Problem I'm having is that it works fine if I delete sheets, but if I decide
to cancel using the "Cancel" button from the warning message, it goes to the
"End If" then "Wend" then cycles again coming back to the warning message
again. Only way to break free is kill the macro by ctrl-break, then end.
Any ideas on how to cancel and have it stop the macro?

Thanks
--
Lee