I have an Excel worksheet with a specific cell for a customer and another cell for a date formatted as mmm dd, yyyy
When writing VBA code to create and record the worksheet as a PDF file in a folder unique to the customer and date, I want to use the the customer and date from the worksheet in the path and filename. However, the date format for the path needs to be "yyyy" and the date format for the file name as "mm-dd-yy"
For example, in the workbook the customer is 004 and date is Jun 07, 2022
The path would be C:\004\2022
The file name would be 06-07-22---004.pdf
My attempt so far:
Sub SaveBilling()
Dim Customer as String
Dim BillDate as String
Dim Path as String
Dim File as String
Customer = Range ("B1")
BillDate = Range ("D1")
Path = "C:\Customer\BillDate\"
File = BillDate & "---" & Customer
'more code here to save as pdf
End Sub
Where in the code do I enter formatting of the dates for the path and file name?
Format (Date, "yyyy"), Format (Date, "mm-dd-yy")
Thanks to all who've assisted in clarifying my prior presentations. Learning to use Stack Overflow has become a skillset in itself!