Sub RemoveSheets()
Dim strNames(1 To 4) As String
Dim ws As Worksheet
ActiveWorkbook.SaveAs ActiveWorkbook.Path & "\newfile"
strNames(1) = "Sheet A"
strNames(2) = "Sheet B"
strNames(3) = "Sheet C"
strNames(4) = "Sheet G"
With Application
.DisplayAlerts = False
.ScreenUpdating = False
End With
On Error Resume Next
For Each ws In ActiveWorkbook.Sheets
If Not Application.WorksheetFunction.Match(ws.Name, strNames, 0) > 0 Then ws.Delete
Next
With Application
.DisplayAlerts = True
.ScreenUpdating = True
End With
End Sub
|