Delete All Worksheets Apart From Some With Particular Name

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

Guest

How would I delete all Worksheets in a Workbook except those called "HOME",
"ONE" and "TWO" (for example).

Thanks!
Dave
 
Sub DeleteSheets()
Dim sht As Worksheet
Application.ScreenUpdating = False

For Each sht In Worksheets
If sht.Name <> "HOME" Then
If sht.Name <> "ONE" Then
If sht.Name <> "TWO" Then
Application.DisplayAlerts = False
sht.Delete
Application.DisplayAlerts = True
End If
End If
End If
Next sht

Application.ScreenUpdating = True
End Sub
 
Back
Top