Reputation: 6081
If I have a global variable in VBA and I assign a value to it on Workbook.open(), is there a way to preserve this assigned value, even if the "Reset" button is clicked in the code (or the code is ended due to a bug)?
Example:
Public myGlobalVariable As String
Private Sub Workbook_Open()
'Ask the user for the value of the global variable
myGlobalVariable = InputBox("Give me some input", "Hi", 1)
End Sub
Upvotes: 0
Views: 217
Reputation: 34045
The only way is to persist them somewhere - eg a cell, defined name, registry, file.
Upvotes: 2