View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mike H. Mike H. is offline
external usenet poster
 
Posts: 471
Default Read Variable from Another Module

That was very helpful. I greatly appreciate the help!

"Jim Thomlinson" wrote:

When refering to variables in other module you just need (or at the very
least should) reference the module and then the variable name to get the
value something like this...

Private Sub Worksheet_calculate()
msgbox Module1.TheWb 'Or whatever the module name is
end sub

Additionally in the module where you declare the variable my preference is
to use the public key word so that I know that the variable is being accessed
from a procedure outside the module

Option Base 1
Public TheWb as String 'Note public instead of just dim

While this is not strictly necessary I like it as a reminder...
--
HTH...

Jim Thomlinson


"Mike H." wrote:

I have a sub: Private Sub Worksheet_calculate(). How can I read a variable
from a module that was set at the top of that module:

Option Base 1
Dim TheWb As String

I want to know what the value of TheWb is while in the calculate sub...