VBA – Prevent warning messages from a macro


When writing a macro there are times when you don’t need to prompt the user with the default warning messages, like “Ok to delete sheet?”. To turn off the default warning messages, add this code to your macro.

Disable Warning Messages in Excel

To prevent warning messages, place this code in your macro

Application.DisplayAlerts = False

Enable Warning Messages in Excel

And don’t forget to turn them back on at some point in your macro

Application.DisplayAlerts = True