I got a question like this:
Is it possible when saving a file in vba to add the current month/year to the end of the filename with the format mmm/yy?
The code I have so far…..
<code>Workbooks(“test.xls”).SaveCopyAs (“C:\xls files\test.xls”)</code>
I need the month/year to be added to test.xls so that it looks like “test_Oct-07.xls”
Let’s do the magic with below codes
Workbooks(“test.xls”).SaveCopyAs (“C:\xls files\test_” & Format(Date,”mmm-yy”) & “.xls”)
Below, it is another sample for adding year and last month in different format:
Path = ActiveWorkbook.Path & "\"
nfname = "SLGA_NCD_" & Format(Now() - 30, "yyyy-mmm") & ".xlsx"