DisplayAlerts not working?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
Can someone possibly explain what's happening with this:
Worksheets(1).Delete
Application.DisplayAlerts = False

This appears to work on occasions - as in, I have the same piece of code
several places, and some of the sheets are deleted without confirmation, some
need confirmation. Anyone any ideas why this is happening?

Thanks
 
You need to turn alerts off prior to the code that will generate the alert
and then be darned sure to turn it back on again when the code completes...

Application.DisplayAlerts = False
Worksheets(1).Delete
Application.DisplayAlerts = True
 
Switch the order:
Application.DisplayAlerts = False
Worksheets(1).Delete
 
Ah thanks, that would explain why it works sometimes and not others as well!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top