Delete Sheet without Warning

  • Thread starter Thread starter Sloth
  • Start date Start date
S

Sloth

how do I supress the warning when deleting a sheet with a macro? I am using
the command following command to delete the sheet.

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

Always set back to true as the property will stay false until reset.

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
 
Try this:

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


HTH,
Paul
 
On a line above the delete sheet statement put the following application
command:

Application.DisplayAlerts = False

Alerts in Excel are automatically reactivated when the macro is finished
running so there's no need to end you macro with an
"Application.DisplayAlerts = True" statement.
 
Do you really need "Sheet1" hard-coded?

Maybe like this in case you want to delete more than one sheet.

Sub SheetDelete()
Application.DisplayAlerts = False
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
End Sub


Gord Dibben MS Excel MVP
 
Kevin, you are wrong on this one. It stays False until you turn it back to
True, even if your macro stops.

Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top