vba turn off alerts in Excel

Q197. In Excel, how can I turn off Alerts using VBA?

For example, I have written a macro to automate a set of routine tasks so that no user intervention is required. However, since my automation involves deletion of WorkSheets (so, whenever code is executed to delete

WorkSheet, pop up message "Data may exist in sheet selectedů..") as well as file overwriting (pop up message confirming if file can be overwritten), user intervention is required. Is there a way to suppress these messages?

To do it in Excel, here is the answer:

  1. Option Explicit
  2. Sub SubRoutineSample()
  3. Application.DisplayAlerts = False
  4. ' complex
  5. ' macro
  6. ' function
  7. ' goes here
  8. Application.DisplayAlerts = True
  9. End Sub


a) Line 3 - Turn OFF Display Alerts when macro is running. This suppresses pop ups. This can be placed at the beginning of code or just before actions that induce pop up messages like WorkSheet deletion, file save etc.,

c) Line 8 - Turn ON Display Alerts after macro is executed.


You can find similar Excel Questions and Answer hereunder

1) How do I update my DropDown list whenever the sheet is activated?

2) How to read a value from a cell in vba in Excel

3) Vba list all files in a folder in Excel

4) How can I add Trendline to a chart using VBA?

5) Determine if hyperlinks are valid in Excel

6) How can I hide a sheet completely from users (the sheet should not even appear in Unhide dialog box)?

7) Vba to return week numbers in Excel

8) Excel 2010 vba replacement of application filesearch in Excel

9) I have a macro that takes a lot of time for execution - how can I keep the user informed that the macro is running?

10) Vba delete entire row if contains certain text in Excel

11) How can I extract file name from a full path including folder path and file name?

12) How do I enter a formula in a cell using VBA (using Absolute Reference)?

13) How can I set Page orientation, Zoom % , Title Rows and footer using VBA?

14) How can I change the Marker size and Marker line color for all the series in a chart?

15) How can I list all files in a folder using VBA?