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

AutoMacro - VBA Code Generator

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!

alt text

Learn More!


<<Return to VBA Examples

VBA Code Examples Add-in

Easily access all of the code examples found on our site.

Simply navigate to the menu, click, and the code will be inserted directly into your module. .xlam add-in.

(No installation required!)