Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Variables Between Workbooks

Greetings,

I have a variable in one workbook that I want any other open workbook
to recognize. For example, workbook A declares variable X. I want
workbook B to also recognize variable X from workbook A.

I am a VBA novice, so please use layman's terms with your reply.

Many thanks,
David

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Variables Between Workbooks

You would need a function in workbookA that would return the value of that
variable

In a general module in WorkbookA.xls
' in the declarations section
Public lngVar as Long

' in the code section
Sub SetVar()
' or some code to set the value of the public variable
lngVar = int(rnd()*1000+1)
End Sub

Public Function MyVariable()
MyVariable = lngVar
End Function

then in the other workbooks you can do

lngA = Application.Run("WorkbookA.xls!MyVariable")

--
Regards,
Tom Ogilvy

wrote in message
ups.com...
Greetings,

I have a variable in one workbook that I want any other open workbook
to recognize. For example, workbook A declares variable X. I want
workbook B to also recognize variable X from workbook A.

I am a VBA novice, so please use layman's terms with your reply.

Many thanks,
David



Reply
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
Not at all clear on use of variables and/or object variables JMay-Rke Excel Discussion (Misc queries) 11 July 4th 08 06:36 PM
Copy/ move selected data from workbooks to seperate worksheets or workbooks Positive Excel Worksheet Functions 1 August 30th 07 04:54 PM
Display 2 formulas from source workbooks to destination workbooks Excel_seek_help Excel Discussion (Misc queries) 4 April 27th 06 08:13 PM
suddenly my excel workbooks are "shared workbooks" Maggie's mom Excel Discussion (Misc queries) 1 August 28th 05 09:20 PM
In Excel how do I put variables in links to other workbooks? bwh2o Excel Worksheet Functions 2 April 22nd 05 03:54 AM


All times are GMT +1. The time now is 12:24 AM.

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

About Us

"It's about Microsoft Excel"