View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
c1802362[_2_] c1802362[_2_] is offline
external usenet poster
 
Posts: 65
Default retaining variable values across modules

If I want to keep a variable in memory through several macros, I can
retain the variable value if I dim it above the subroutines in the
module

So, in module 1:

Dim String1 as String

Sub test1()
string1 = " test"
end sub

sub test2()
msgbox string1
end sub

the value of string1 is retained into sub test2, test 3, etc

However, all my attempts to retain the value of string1 from module 1
to another module nulls the value of string1.

How do I maintain the value of a variable across modules, not only
within a module?

Art