Help deleting worksheets

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top