LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default 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
 
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
Global Variable dhstein Excel Discussion (Misc queries) 4 July 26th 09 05:10 PM
Use of global between workbooks Busy Bee Excel Programming 3 October 11th 07 01:16 PM
How to share variable values between 2 Workbooks ? Yves Le Hurt Excel Programming 2 January 19th 06 12:17 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
Global variable Don[_11_] Excel Programming 1 October 28th 03 04:15 AM


All times are GMT +1. The time now is 08:14 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"