I have some vba code that saves a file to a specific folder based on the month. The month is set by the user as a two digit format (01, 02, etc) and set as a variable in my vba code. However, when I run the code the file doesn't save, and I've found that it has to do with the fact that the variable is only holding one digit when the month is < 10, in other words, it drops the leading 0.
What code can I use to keep the leading 0?
The formula I'm using for the date is:
=TEXT(A1,"mm")
(A1 contains the date)
What code can I use to keep the leading 0?
Code:
Workbk2.SaveAs Filename:= "G:\Accounting\HotShop Reports\" & rptYear & "\00-Hotshop Critique\" & rptMonth & "\HS_Critique_" & username3 & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
The formula I'm using for the date is:
=TEXT(A1,"mm")
(A1 contains the date)