LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Public variables and separate library files

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
public variables johnny Excel Discussion (Misc queries) 7 February 27th 08 03:44 PM
Public variables johnny Excel Discussion (Misc queries) 2 February 24th 08 05:05 AM
Public Variables Jerry McNabb Excel Discussion (Misc queries) 0 February 24th 08 01:26 AM
public but private variables No Name Excel Programming 2 May 19th 04 12:41 PM
Public Variables with UserForms Mark Worthington Excel Programming 3 February 26th 04 12:26 AM


All times are GMT +1. The time now is 03:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"