Hi
I'm trying to delete 30 sheets from a spreadsheet with VBA.
The spreadsheet has about 50 sheets, but I only want to delete the ones with the word "auto" at the end of the sheet name.
I've written this and it has cleared the contents of those sheets.
But I want to delete them without prompts.
Can anyone advise how I need to change this please?
I'm trying to delete 30 sheets from a spreadsheet with VBA.
The spreadsheet has about 50 sheets, but I only want to delete the ones with the word "auto" at the end of the sheet name.
I've written this and it has cleared the contents of those sheets.
But I want to delete them without prompts.
Can anyone advise how I need to change this please?
Code:
Sub DeleteSheets()
Dim sht As Worksheet
For Each sht In ThisWorkbook.Worksheets
If Right(sht.Name, 4) = "auto" Then
Application.DisplayAlerts = False
sht.Cells.Delete
Application.DisplayAlerts = True
End If
Next
Exit Sub
End Sub