Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variables not recognized
Hello All,
Im using Excel 2003 and coding in MS VB. Ive declaring variables in Module 1 Window and created code in Module 1 and Module 7 Windows. I having problem with variable in Module 7 Windows. The variables are recognized in M7 while stepping through the code. However, while stepping from M7 to M1, the variables are not recognized in M1 Window. How is this problem corrected? Thanks in advance! Paul |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variables not recognized
If you want the variables to be recognized in two different procedures at module level, the variables must be declared as public variables, out side any procedu This can be done in any module. For examaple the module (1 or 7) should look like below: Public myNumber As Integer, myString As String Public '...more public declarations Sub MyCode() 'code End Sub. So define the vairables as Public (not Dim) and define them outside any Sub procedure. Sharad *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variables not recognized
try the following:
Make the FIRST line of M1: Option Explicit 'this will force you to declare variables, which is highly recommended Make line 2 of M1: Public MyVariable1 as String (or as Range etc) Use the word "Public" in place of "Private" or "Dim" The declaring a variable as "Public" will make it available across modules. Once you assign a value to a public variable, say in a procedure in M1, the value will remain with your variable and can be used in another procedure in say M7. The variable VALUE will stay with that variable until you assign a new value or until you close the file. "Paul" wrote: Hello All, Im using Excel 2003 and coding in MS VB. Ive declaring variables in Module 1 Window and created code in Module 1 and Module 7 Windows. I having problem with variable in Module 7 Windows. The variables are recognized in M7 while stepping through the code. However, while stepping from M7 to M1, the variables are not recognized in M1 Window. How is this problem corrected? Thanks in advance! Paul |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
UDF Not recognized | Excel Worksheet Functions | |||
value not recognized as a formula | Excel Worksheet Functions | |||
One cell isn't recognized? | Excel Discussion (Misc queries) | |||
Data isn't being recognized. | Excel Worksheet Functions | |||
ActiveCell not recognized | Excel Programming |