Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How does one make a variable available to other routines stored in a
separate library-type file? I thought using "Public", but in the simple example below the variable "temp" is null within the called subroutine… Calling file… Public temp As Integer Sub Master() Workbooks.Open ("\Temp\Library1.xls") temp = 0 Again: MsgBox ("Befo" & temp) Application.Run "Library1.xls!TestSub" MsgBox ("After:" & temp) temp = temp + 1 GoTo Again End Sub File "\Temp\Library1.xls"… Sub TestSub() MsgBox ("Within:" & temp) End Sub Output produced… Befo0 Within: After:0 Befo1 Within: After:1 Befo2 Within: After:2 etc. If I add a "Public" statement at the top of the Library1.xls module, I get zeros instead of nulls within the called routine. (It works correctly if I concatenate the two routines into the same file, but this of course defeats the purpose of having separate libraries of code). |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
public variables | Excel Discussion (Misc queries) | |||
Public variables | Excel Discussion (Misc queries) | |||
Public Variables | Excel Discussion (Misc queries) | |||
public but private variables | Excel Programming | |||
Public Variables with UserForms | Excel Programming |