R
ryguy7272
I found some VBA code (on this Discussion Group that was posted a while back)
which allows a user to delete all worksheets except for three. I am
wondering if there is a way to get Excel to delete all worksheets which don’t
have “ZZZ†in the tab. I tried “ZZZ*†but didn’t have any success with that.
Basically, I am wondering if the * (wildcard) symbol is not recognized in
VBA…
My code is below:
Sub DelteAllWS()
Dim mySht As Worksheet
Application.DisplayAlerts = False
For Each mySht In ActiveWorkbook.Worksheets
If mySht.Name <> "ZZZ - USA Firms" And mySht.Name <> "ZZZ - RQ 2000-2006"
And mySht.Name <> "ZZZ - 2006 Pulse Global 600" Then
mySht.Delete
End If
Next mySht
Application.DisplayAlerts = True
End Sub
Would like to use:
If mySht.Name <> "ZZZ*" Then
mySht.Delete
...............................................
Thanks!
which allows a user to delete all worksheets except for three. I am
wondering if there is a way to get Excel to delete all worksheets which don’t
have “ZZZ†in the tab. I tried “ZZZ*†but didn’t have any success with that.
Basically, I am wondering if the * (wildcard) symbol is not recognized in
VBA…
My code is below:
Sub DelteAllWS()
Dim mySht As Worksheet
Application.DisplayAlerts = False
For Each mySht In ActiveWorkbook.Worksheets
If mySht.Name <> "ZZZ - USA Firms" And mySht.Name <> "ZZZ - RQ 2000-2006"
And mySht.Name <> "ZZZ - 2006 Pulse Global 600" Then
mySht.Delete
End If
Next mySht
Application.DisplayAlerts = True
End Sub
Would like to use:
If mySht.Name <> "ZZZ*" Then
mySht.Delete
...............................................
Thanks!