Macro to delete sheets

  • Thread starter Thread starter Jodie
  • Start date Start date
Application.DisplayAlerts=False
Worksheets("PLANID ").Delete
Worksheets("FEETOTAL ").Delete
Application.DisplayAlerts=True
 
remove the unwanted space after the sheet name and quote mark - happened
when I copied the names.
Application.DisplayAlerts=False
Worksheets("PLANID").Delete
Worksheets("FEETOTAL").Delete
Application.DisplayAlerts=True
 
Try this
Sub deleteSheets()
Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets
With Application
.DisplayAlerts = False
With ws
If .Name = "PLANID" Or .Name = "FEETOTAL" Then
.Delete
End If
End With
.DisplayAlerts = True
End With
Next
End Sub
 
try this
Sub deleteSheets()
Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets
With Application
.DisplayAlerts = False
With ws
If .Name = "PLANID" Or .Name = "FEETOTAL" Then
.Delete
End If
End With
.DisplayAlerts = True
End With
Next
End Sub
 
Sub Macro()
Application.DisplayAlerts = False
Sheets("Sheet2").Delete
'To delete more than one sheet
'Sheets(Array("Sheet2", "Sheet3")).Delete
Application.DisplayAlerts = True
End Sub

If this post helps click Yes
 
Sub SheetKiller()
Application.DisplayAlerts = False
Sheets("PLANID").Delete
Sheets("FEETOTAL").Delete
Application.DisplayAlerts = True
End Sub
 
Sub Macro()
Application.DisplayAlerts = False
Sheets("PLANID").Delete
'to delete both
'Sheets(Array("PLANID","FEETOTAL")).Delete
Application.DisplayAlerts = True
End Sub

If this post helps click Yes
 
Thank you Mike, this worked great and did not give me any pop up messages
about permanently deleting sheets.
 
Back
Top