deleting sheets without excel asking

P

Phil

I'm using this code to delete a sheet:

Sheets("START").Select
ActiveWindow.SelectedSheets.Delete

When I do this excel says there may be data on the sheet do you really want
to delete it? And then you have to click delete.
Is there a way to have it delete the sheet without having the user click
delete?

Thanks,
Phil
 
D

David McRitchie

Hi Phil,
You can delete a sheet without making it active.

'Delete a sheet
Application.DisplayAlerts = False
Sheets("START").Delete
'--Activesheet.Delete
'--ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True

Worksheets in VBA Coding and in Worksheet Formulas
http://www.mvps.org/dmcritchie/excel/sheets.htm
 
D

Don Guillett

try this.

Sub deletesheet()
Application.DisplayAlerts = False
Sheets("sheet10").Delete
End Sub
 
Top