![]() |
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 |
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 |
All times are GMT +1. The time now is 05:35 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com