Delete sheets starting with the name "sheet"

fari1

Active Member
Joined
May 29, 2011
Messages
362
hi, i want a code, that may run in my workbook and delete all the sheets, that are starting with the name of "sheet", it can be anything after sheet.

it can be sheet1, sheet300 or sheet3 etc.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Following code should do:
Code:
Public Sub DelShts()
Application.DisplayAlerts = False
For i = Sheets.Count To 1 Step -1
If UCase(Left(Sheets(i).Name, 5)) = "SHEET" Then Sheets(i).Delete
Next i
Application.DisplayAlerts = True
End Sub
 
Upvote 0
i want a code

Not a very friendly greeting for someone who is asking a favor :-(

Anyway.

Code:
Dim I As Integer
Application.DisplayAlerts = False
For I = Sheets.Count To 1 Step -1
  If Sheets(i).Name Like "sheet*" Then Sheets(i).Delete
Next
Application.DisplayAlerts = True
 
Upvote 0
Respected wigi, next time i'll be seeking for some gud diction before posting here
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,225
Members
452,896
Latest member
IGT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top