Values assigned to variables staying in memory when procedure stop
Hi Peter,
Module level variables retain their assigned values (unless cleared)
throughout an Excel session.
---
Regards,
Norman
"Peter Rooney" wrote in message
...
Good afternoon, again!
I have a Worksheet_Change macro that only kicks in if the TARGET is within
certain worksheet boundaries.
Within this macro, I have a MSGBOX that displays the values of the
variables
containing the first/last rows/columns in my "Database" range, which are
usually set by a macro called DefineDatabase. However, although
DefineDatabase isn't run before the MSGBOX is displayed, it displays the
correct values! The variables in question are declared at Module and not
Procedure level.
DefineDatabase HAS been run several times times throughout the morning as
part of my testing, and it doesn't contain any commands to set the
variables
to zero before it starts, or when it finishes.
I somewhat mistakenly thought that when a macro stopped running, the
values
held by variables were reset to NOTHING/NIL/NADA/ZERO. Is this not the
case?
The variables concerned are declared as PUBLIC, so as to be available to
macros in more than one module, but they're not STATICs or anything like
that.
It's probably just a Friday afternoon thing, but I'd be grateful if
someone
could help me out here, otherwise I'm liable to spend all weekend thinking
"...but how dows it KNOW?"
Yes, I know I should get out more often..! :-)
Thanks in advance and have a good weekend
Pete
|