Macro to delete sheets

P

Patrick Molloy

Application.DisplayAlerts=False
Worksheets("PLANID ").Delete
Worksheets("FEETOTAL ").Delete
Application.DisplayAlerts=True
 
P

Patrick Molloy

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
 
M

Mike

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
 
M

Mike

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
 
J

Jacob Skaria

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
 
G

Gary''s Student

Sub SheetKiller()
Application.DisplayAlerts = False
Sheets("PLANID").Delete
Sheets("FEETOTAL").Delete
Application.DisplayAlerts = True
End Sub
 
J

Jacob Skaria

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
 
J

Jodie

Thank you Mike, this worked great and did not give me any pop up messages
about permanently deleting sheets.
 
Top