ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Variable available to all open xl files (https://www.excelbanter.com/excel-programming/421673-variable-available-all-open-xl-files.html)

steven

Variable available to all open xl files
 
Is there a way to declare a variable that will be recognized by open excel
files? For example if I have 2 files and in File1 I set a variable
vAllFilesVariable = "It works" then if I am in File2 and put MsgBox
vAllFilesVariable on the SelectionChange is there a way to make it so it
would return the variable?

Thank you,

Steven

Héctor Miguel

Variable available to all open xl files
 
hi, Steven !

Is there a way to declare a variable that will be recognized by open excel files?
For example if I have 2 files and in File1 I set a variable vAllFilesVariable = "It works"
then if I am in File2 and put MsgBox vAllFilesVariable on the SelectionChange
is there a way to make it so it would return the variable?


without linked references between vba-projects ?... (one way)

File1 (the file with the variable)
- standard code module:
Public vAllFilesVariable As String
Function WhatsOnMyVariable() As Variant
WhatsOnMyVariable = vAllFilesVariable
End Function

- workbook_open event
Private Sub Workbook_Open()
vAllFilesVariable = "It Works !!!"
End Sub

File_X
- standard code module
Sub VariableOtherWorkbook()
MsgBox Application.Run("file1.xls!whatsonmyvariable")
End Sub

hth,
hector.




All times are GMT +1. The time now is 12:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com