Suppressing Excel Warnings

Some messages appear even if you have set Excel to ignore errors. Try to delete a worksheet using code, and you will still get the message Data may exist in the sheet(s) selected for deletion. To permanently delete the data, click Delete. This is annoying. We don't want our clients to have to answer this warning. It turns out that this is not an error, but an alert. To suppress all alerts and force Excel to take the default action, use Application.DisplayAlerts = False:

Sub DeleteSheet()

Application.DisplayAlerts = False Worksheets("Sheet2").Delete Application.DisplayAlerts = True End Sub

0 0

Post a comment