I'm trying to declare a public variable strFileDate
that I would like to store an input box value to be later referenced when another workbook (separate wb) is opened and a macro is run within that new wb. I declare a public variable as so:
Public strFileDate as string
Option Explicit
Sub Update_Data()
Dim strFileDate As String: strFileDate = InputBox("Enter Folder Date (mm.dd.yy)", Default:=Format("mm.dd.yy"))
...
end sub
Option Explicit
Sub Open_Separate_File
Dim basepath as string: basepath = "C:\...."
Dim strFileName as string: strFileName = "test_file_"
Thisworkbook.SaveCopyAs basepath & strFileName & strFileDate & ".xlsx"
End Sub
whenever I open up the workbook containing Open_Separate_File
, it says that strFileDate
is not defined, and I assume it's due to the Option Explicit
label at the top of both modules. Is there a way around this without omitting Option Explicit
?