svendiamond
Well-known Member
- Joined
- Jun 13, 2014
- Messages
- 1,504
- Office Version
- 365
- Platform
- Windows
How do I get my workbook to declare public variables on the Workbook.Open event? The following code gives an error because I'm trying to declare a public variable inside a sub-routine (this is in the "ThisWorkbook" code)
But that's basically what I want to do... as soon as the workbook opens I want to set up this variable. What about this:
^ but would that work? How does Excel know to declare that variable on the Workbook.Open event when it's not in that sub-routine?
Code:
Private Sub Workbook_Open()
Public enableTestMode As Boolean
enableTestMode = Range("i_enableTestMode").Value
End Sub
But that's basically what I want to do... as soon as the workbook opens I want to set up this variable. What about this:
Code:
Public enableTestMode As Boolean
Private Sub Workbook_Open()
enableTestMode = Range("i_enableTestMode").Value
End Sub
^ but would that work? How does Excel know to declare that variable on the Workbook.Open event when it's not in that sub-routine?