![]() |
Read Variable from Another Module
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... |
Read Variable from Another Module
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... |
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... |
All times are GMT +1. The time now is 05:14 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com