Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Help deleting worksheets
I have a spreadsheet that has a huge number of worksheets that need to be
deleted. I want to use a wildcard in the criteria as the sheet naming convention is admin_user and there are 70 users. Hence I want to delete any sheet that starts admin_. I have tried a wildcard in an "if" statement but it does not work. Any help would be greatly appreciated. |
#2
|
|||
|
|||
Try this. Back up your workbook first. You can't undo the deletions.
Sub RemoveAdminSheets() Dim shTest As Worksheet If MsgBox("Have you backed up this workbook?", vbYesNo) = vbNo Then Exit Sub Application.DisplayAlerts = False For Each shTest In Worksheets If shTest.Name Like "admin_*" Then shTest.Delete Next shTest Application.DisplayAlerts = True End Sub Robin Hammond www.enhanceddatasystems.com "Wilhelmutt" wrote in message ... I have a spreadsheet that has a huge number of worksheets that need to be deleted. I want to use a wildcard in the criteria as the sheet naming convention is admin_user and there are 70 users. Hence I want to delete any sheet that starts admin_. I have tried a wildcard in an "if" statement but it does not work. Any help would be greatly appreciated. |
#3
|
|||
|
|||
That works just fine! Thank you.
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Count of Worksheets | Excel Discussion (Misc queries) | |||
How to protect and unprotect 30 worksheets in a file every month . | Excel Worksheet Functions | |||
Protect/unprotect all worksheets | Excel Worksheet Functions | |||
HELP! How do you--> Lock a set of rows but also link worksheets to | Excel Discussion (Misc queries) | |||
Assigning Cells in worksheets to other data in other worksheets. | Excel Discussion (Misc queries) |