Programmatically deleting sheets


Posted by Adam T. Dickson on October 16, 2001 10:07 AM

I am attempting to programmatically delete sheets in Excel, after their data has been copied into another sheet. I am using the following simple code:

Sheets(sheet1).Select
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.Delete

This works just fine for deleting the sheet; the problem is, it brings up a dialog box asking if you're sure you want to delete the sheet. This means the user has to interact with the macro, and therefore cannot run unattended.

Does anyone know how to programmatically click the okay button (or make the dialog box not pop up at all?

Thanks!



Posted by Dan on October 16, 2001 10:54 AM

Try this code -

Application.DisplayAlerts = False
Sheets("Sheet1").Delete
Application.DisplayAlerts = True

HTH