What would be the best way to delete all the sheets in the active Workbook, except the selected/active sheet and 4 specified sheets, using their CodeNames?
I've come up with this code and it works, but it seems like there would be a better way to do it:
Sub delete_test()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
'Deletes all sheets except ActiveSheet and specified sheets using codenames
Dim ws As Worksheet
For Each ws In ThisWorkbook.Sheets
Select Case ws.CodeName
Case "Sheet1", "Sheet2", "Sheet3", "Sheet4"
Case Else
With ws
If ws.NAme <> ThisWorkbook.ActiveSheet.NAme Then
ws.Delete
End If
End With
End Select
Next
End Sub