Use macro to delete worksheet without specific name Eg:Sheet 1

D

Delight

Hello Everybody,

Need help again !! I need a macro to delete active worksheets without a
specific
worksheet name eg: Sheet7, Sheet8 & Sheet9, etc. I had tried this statement
but it don't work.. Is there anyone can help me ??

Activesheet.Delete

Thank You Very Much !!!
 
G

Gary''s Student

Sub JustKillMe()
Application.DisplayAlerts = False
ActiveSheet.Delete
Application.DisplayAlerts = True
End Sub
 
S

Simon Lloyd

I think a much better version of the code would be:

Sub Del_Sheets()
Dim sh As Worksheet
Application.DisplayAlerts = False
For Each sh In Sheets
If Left(sh.Name, 5) = "Sheet" Then
sh.Delete
End If
Next
Application.DisplayAlerts = True
End Sub


--
Simon Lloyd

Regards,
Simon Lloyd
'www.thecodecage.com' (http://www.thecodecage.com)
 
D

Delight

Hello Everybody,

Thanks for the help !! Simon, I followed your method and I get what I want.

Thanks !!
 
Top