Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Share global variable between workbooks
Using Office 2007 and Win XP;
I need to share a global variable between workbooks in the same instance of XL; The variable is loaded in a standard code module of Book-A; in Book-B, there is code in the "ThisWorkbook" module that needs to retrieve the contents of the variable. 1) Is this possible? 2) If possible, can someone please explain or better yet, post a generic example illustrating how to do this? Thanks much in advance for your assistance! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Share global variable between workbooks
If you have a set of workbooks that are all open at the same time, just
assign some cell in one of the workbooks to hold the variable. This way VBA can retrieve/modify the variable just like any other cell. An alternative is to assign some registry key to hold the variable and use savesetting/getsetting -- Gary''s Student - gsnu200810 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Share global variable between workbooks
On Oct 29, 9:08 am, XP wrote:
Using Office 2007 and Win XP; I need to share a global variable between workbooks in the same instance of XL; The variable is loaded in a standard code module of Book-A; in Book-B, there is code in the "ThisWorkbook" module that needs to retrieve the contents of the variable. 1) Is this possible? 2) If possible, can someone please explain or better yet, post a generic example illustrating how to do this? Thanks much in advance for your assistance! It is possible. Declare the variable in Book-A as module level Public variable. Then have Book-B reference Book-A. You should give Book-A project some name other than VBAProject. Then go to Tools/References and check that project. Then you can refer to the variable using the ProjectName.PublicVariable syntax. So if you: named the project for Book-A = MyData named the Book-A public variable = MyVariable then after referencing MyData from Book-B you could retrieve MyVariable like this x = MyData.MyVariable |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Global Variable | Excel Discussion (Misc queries) | |||
Use of global between workbooks | Excel Programming | |||
How to share variable values between 2 Workbooks ? | Excel Programming | |||
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? | Excel Worksheet Functions | |||
Global variable | Excel Programming |