VBA – Prevent warning messages from a macro

Associated Files Download Links

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

1

Application.DisplayAlerts=False

Enable Warning Messages in Excel

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

1

Application.DisplayAlerts=True

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro – A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!