XLA Routines: EE_DeleteSheets

Nick's picture
Following on from EE_DeleteSheet, here's a routine that deletes multiple sheets
Sub EE_DeleteSheets(ArrayOrRange)
    Dim blnDisplayAlerts    As Boolean
    Dim arr
    Dim wbk                 As Workbook
'http://excelexperts.com/xla-routines-eedeletesheets
    
    Set wbk = ActiveWorkbook
 
    Select Case TypeName(ArrayOrRange)
        Case "Variant()", "String"
            arr = ArrayOrRange
        Case "Range"
            arr = Application.Transpose(ArrayOrRange.SpecialCells(xlCellTypeConstants))
        Case Else
    End Select
 
    blnDisplayAlerts = Application.DisplayAlerts
    Application.DisplayAlerts = False
 
    On Error Resume Next
        wbk.Worksheets(arr).Delete
    Err.Clear: On Error GoTo 0: On Error GoTo -1
 
    Application.DisplayAlerts = blnDisplayAlerts
 
    Set wbk = Nothing
End Sub