Hi,
The following code wasn't tested:
- Code: Select all
Public Sub DeleteSheets()
Dim R as Long
For R = 10 to 80
Application.DisplayAlerts = False
Worksheets(Cstr(ActiveSheet.Cells(R, 2).Value)).Delete
Application.DisplayAlerts = True
Next R
End Sub
It also has no safeguards. If the name in column B isn't a valid name the macro will crash. If it crashes the Option "DisplayAlerts" will be caught switched off. You can switch it on by typing the command in the Immediate Window of the VB Editor or by restarting Excel.
Install this macro in The ThisWorkbook or any Code module in your workbook where the list is. The sheets to be deleted must be in the same workbook. Call the macro by selecting it from the list of available macros you get from Tools/Macro/Macros and pressing Run. If you choose to run it from the VB Editor instead, make sure that the ActiveSheet is the one with the list in it. The ActiveSheet is the worksheet that you last saw before switching to the VB Editor.
I strongly suggest that you try it out by setting the For ... Next loop to a single worksheet, like
For R = 10 to 10
Have a great day!
Sisyphus
I do this for "honour and country" - much less of the latter, actually.
If I helped you, award points, plenty of them.
If I bored you, deduct points for being too long-winded. (I know, :lol)