In this article we will learn how to turn off warning message using VBA in Microsoft Excel 2010.
When we run vba code / macros in our excel files, we see a lot of screen flickering as the actions are being performed on the file. Also, we get popup messages asking to accept the “Save” or “Delete” as per the code. We can disable these so that the code can run from start to end without disturbing the user. One such alert is shown below -
You can turn off these notifications while the code is running and then turn them on once the code is done.
To prevent the screen from flickering, we enter
Application.ScreenUpdating = False at the beginning of the code and Application.ScreenUpdating = True at the end of the code.
Similarly, to prevent the alerts from appearing, we enter
Application.DisplayAlerts = False at the beginning of the code and Application.DisplayAlerts = True at the end.
This is how it looks in the code window –
Here is the code –
‘Dim statements here
Application.ScreenUpdating = False
Application.DisplayAlerts = False
‘Your code here
Application.ScreenUpdating = True
Application.DisplayAlerts = True
To copy this code into your file’s code window, press Alt + F11 on your keyboard. On the left hand side you will see Microsoft Excel Objects. Right click and select Insert. Then click on Module.
Copy the code into the code window on the right.
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.