Save File With Previous 'Month' In FileName

Small Paul

Board Regular
Joined
Jun 28, 2018
Messages
118
Hi All

I have been working on opening/saving files using previous day.
I now need to 'save' a workbook with previous month in the filename.
The code I have is based on what has worked before:

Code:
    Sheets("Monthly CAC Report").Select    ActiveWorkbook.Names.Add Name:="Locator", RefersToR1C1:= _
        "='Monthly CAC Report'!R524288C8192"
    Sheets("Monthly CAC Report").Select
    Sheets("Monthly CAC Report").Copy
    ChDir "Z:\Promotional and marketing\Product Performance\Monthly Data"
    ActiveWorkbook.SaveAs Filename:= _
        "Z:\Promotional and marketing\Product Performance\Monthly Data\CACS " & Format(Now() - 1, "MMM-YYYY") & " PS Test.xlsx" _
        , FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
End Sub

Unfortunately, this saved the file as "CACS Jul-2018 PS Test"

I was hoping that, as I am using format MMM-YYYY it would save as 'June 2018'.

Any thoughts would be appreciated.

Cheers
Small Paul.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top