L
Lee
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
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