Delete Sheets in Excel

Closed
ujo Posts 8 Registration date Wednesday July 15, 2009 Status Member Last seen September 23, 2009 - Jul 22, 2009 at 02:38 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Jul 22, 2009 at 05:45 AM
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 response

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Jul 22, 2009 at 05:45 AM
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