Variable available to all open xl files

S

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?

Thank you,

Steven
 
H

Héctor Miguel

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top