View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default can variables pass values

A global variable is visible by all routines in a project - so it isn't
passed.

At the top of a general module, outside any procedure declare the variable
as

Public MyCell as Range

or whatever is appropriate for your variable

for your question, if a variable goes out of scope, it doesn't exist. If
you refer to it in a procedure where it is out of scope, you create a new
variable with the same name which will have a value of empty since it will
be an uninitialized variant. (unless you have option explicit at the top,
then it will raise an error).
--
Regards,
Tom Ogilvy

Don wrote in message
...
I've written a program that starts a sub procedure each
minute (which is started with the application.ontime
event) that takes a value from a cell and puts it into
the next cell down a column. The problem is that it works
well as long as I use active cells, which I can't use.

THE QUESTION IS: can I pass the value of a global
variable from one procedure to the next or does the
variable return to zero or garbage when it goes out of
scope from one procedure to another? I really need to
pass an index value from one procedure to the next.
Any ideas at all? Declaring static seems to not work as
in VB.