Hey all,
Kinda new at this excel/VBA gig.
Trying to automate some tasks.
The date can be changed manually in the Excel Spreadsheet.
For ex. in this Spreadsheet
B2 is 05
B3 is 27
B4 is 2020
This is the code I'm using to open a file whose name changes based on date.
Sub openvarpt2()
Dim varCellday As Long
Dim varCellmonth As Long
Dim varCellyear As Long
varCellday = Range("B2").Value
varCellmonth = Range("b3").Value
varCellyear = Range("b4").Value
Workbooks.Open "M:\R\2020\EFR - " & varCellmonth & "." & varCellday & "." & varCellyear & ".xlsm"
End Sub
the file path is: M:\R\2020\EFR - 05.27.2020.xlsm
I keep getting an error msg because the "05" gets picked up by the code as only a "5". I formatted it to text already in Excel.
By the way, it works when i change the code to:
Workbooks.Open "M:\R\2020\EFR - " & "0" & varCellmonth & "." & varCellday & "." & varCellyear & ".xlsm"
Any thoughts?
Thanks!
Bookmarks