• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Need VBA code to delete all sheets that start with Sheet

txfrazier

New Member
I have a number of users of a workbook that contains a number of pivot tables. When the user views the data behind the table, a new sheet is displayed. I know its not difficult to simply delete the new sheet, but you don't understand my users. Therefore, I'd like to have code that deletes ALL sheets whose name includes "Sheet" regardless of whther its Sheet1, Sheet2, etc.


Thanks
 
This will delete any worksheet with the word "sheet" in its name.

Code:
Sub KillSheets()
Application.ScreenUpdating = False
For Each ws In ThisWorkbook.Worksheets
If UCase(ws.Name) Like "*SHEET*" Then
Application.DisplayAlerts = False
ws.Delete
Application.DisplayAlerts = True
End If
Next
Application.ScreenUpdating = False
End Sub
 
Last edited by a moderator:
Back
Top