Where to put DisplayAlerts = False

  • Thread starter Thread starter Joe Fish
  • Start date Start date
J

Joe Fish

Hi,
I have tried inserting DisplayAlerts = False all over the following
block of code , but when I go to delete the sheets, it still asks if I
want to delete them. Is this not the right syntax or am I doing
something wrong?
Thanks,
Joe Fish

Sub SetUpScrollerInfo()

DisplayAlerts = False
Run ("DeleteOldSheets")
Run ("MakeNewSheets")
Run ("ImportData")
Run ("FormatData")
Run ("AddToPositionAndUnitNumberFormula")
Run ("DefineBundles")
Sheets("Scroller Info").Range("A1").Select

End Sub
Sub DeleteOldSheets()

DisplayAlerts = False
Sheets("Scroller Info").Delete
DisplayAlerts = False
Sheets("Spare Scroller Cables").Delete
 
You need to qualify 'DisplayAlerts' with 'Application'. E.g,

Application.DisplayAlerts = False

Without the Application qualification, VBA treats 'DisplayAlerts'
as a variable name, creates the variable, and assigns it a value
of False. This would be obvious if you properly placed 'Option
Explicit' at the top of your code module.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
change to:
Application.DisplayAlerts = False
Your code....
Application.DisplayAlerts = True
 
Back
Top