Delete Sheets in Excel [Closed]

Report
Posts
8
Registration date
Wednesday July 15, 2009
Status
Member
Last seen
September 23, 2009
-
Posts
1862
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
July 30, 2015
-
Hello,

I am looking for a VBA macro that can delete all the sheets in Excel the start with name "Sheet".
Also if no such sheet name is found it should give a simple msg box saying No sheet found. And if delete is successful it should say Sheets deleted.

Regards
Ujo

1 reply

Posts
1862
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
July 30, 2015
792
Tha macro is

Sub test()
Dim j As Integer, k As Integer
Application.DisplayAlerts = False
j = Worksheets.Count
For k = 1 To j
If Worksheets(k).Name = "sheet" Then
Worksheets(k).Delete
GoTo line1
End If
Next k
line1:
Application.DisplayAlerts = True
End Sub
1
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2942 users have said thank you to us this month

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!