Macro to delete sheets listed in column A of sheet 1

shammie4

New Member
Joined
Nov 15, 2006
Messages
17
Hi all,
I made a terrible mistake and created a bunch of sheets in an excel file. There are about 350 sheets in all. I need to remove about 55. I have a list of the sheets to be removed in column A.
Does anyone know a macro that can delete those sheets?

Thanks!
 

Some videos you may like

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
If your list of sheets to delete is on Sheet1 column A, try

Code:
Sub DeleteSheets()
Dim lr As Long, i As Long
Application.DisplayAlerts = False
With Sheets("Sheet1")
    lr = .Cells(Rows.Count, "A").End(xlup).Row
    For i = 1 to lr
        Sheets(.Cells(i, "A").Value).Delete
    Next i
End With
Application.DisplayAlerts = True
End Sub
 

shammie4

New Member
Joined
Nov 15, 2006
Messages
17
Wow Thanks. All those sheets that I created in error are gone!IT was such a pain deleting them one by one.
You rock!
 

Watch MrExcel Video

Forum statistics

Threads
1,122,745
Messages
5,597,887
Members
414,185
Latest member
tarun19954

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
Top