hi,
If x is declared within the "open" sub it will only hold its value for
as long as the "open" sub is running. To make it hold its value you may
be able to declare it as Static (see Help files). However, I have read
that the Static keyword can be unreliable.
Another approach is to define a named range in your file & change its
value once the deactivate macro has been run once, and then reset it
next time the file opens, eg:
(recorded in Excel 2007*)
VBA Code:
--------------------
'in the Open macro
ActiveWorkbook.Names.Add Name:="DeactivateMacroHasRun", RefersToR1C1:="=""F"""
'in the deactivate macro
With ActiveWorkbook.Names("DeactivateMacroHasRun")
If .Value = "=""T""" Then Exit Sub
.RefersToR1C1 = "=""T"""
End With
'rest of code...
--------------------
hth
Rob
--
broro183
Rob Brockett. Always learning & the best way to learn is to
experience...
------------------------------------------------------------------------
broro183's Profile: 333
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=187313
http://www.thecodecage.com/forumz/chat.php