Re: Gathering Values on Workbook Open for use later in subroutines
Did you declare them outside of the subroutine?
Code
Public varWorkbooksAddress As String
Public varWorkbooksRow As String
Public varWorkbooksCol As String
Private Sub Workbook_Open()
'THIS SUBROUTINE LOADS THE INITIAL PARAMETERS WHEN THE WORKBOOK OPENS
'TODO: Need to set up error trapping to warn &/or escape if fails.
'DEFINING VARIABLES
'SETTING VARIABLES
'varWorkbooksAddress = Cell location of first workbook to track
Sheets("Parameters").Select
Cells.Select
Selection.Find _
(What:="Worksheet 1", After:=ActiveCell, LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
varWorkbooksAddress = ActiveCell.Address
varWorkbooksRow = ActiveCell.Row
varWorkbooksCol = ActiveCell.Column
'FINISH UP
Cells(1, 1).Select ' PARKING Cell
End Sub
Display More
Depending on the size of your application, you may consider using a separate module to keep track of only your global variables. This way it is easy to keep track of them and have them in one place.
Global variables will only last the lifetime of the application, that is as long as that particular Excel workbook is open. If you'll need these values after the user has closed and re-opened the workbook, you may consider a hidden worksheet where you record variable values (perhaps in the Workbook_Save event, for example) and then you can read them on open the next time.