Forum Discussion

calof1's avatar
calof1
Iron Contributor
May 04, 2021
Solved

Help to update Macro to save CSV file with month and year in file name

Hi All,

 

Each month i have some data i need to upload, so save this as a CSV using a macro. I am hoping to have the file name updated to match the Month and year listed in cells C2 & C3 of my spreadsheet.

 

If anyone has any suggestions on how to assist with this, it would be greatly appreciated.

 

Kind regards,

 

Callum

  • calof1 

    Change the line

     

    destinationSheet.SaveAs Filename:=saveToLocation & "\csvfile.csv", FileFormat:=xlCSV, CreateBackup:=False

     

    to

     

    destinationSheet.SaveAs Filename:=saveToLocation & "\" & Format(Date, "mmmm yyyy") & ".csv", FileFormat:=xlCSV, CreateBackup:=False

5 Replies

  • calof1 

    Change the line

     

    destinationSheet.SaveAs Filename:=saveToLocation & "\csvfile.csv", FileFormat:=xlCSV, CreateBackup:=False

     

    to

     

    destinationSheet.SaveAs Filename:=saveToLocation & "\" & Format(Date, "mmmm yyyy") & ".csv", FileFormat:=xlCSV, CreateBackup:=False

    • calof1's avatar
      calof1
      Iron Contributor
      Hi Hans,

      Thanks a lot for your help with this, it works exactly as I was hoping for. This is very much appreciated.

      I have also noticed the macro includes the entire sheet. If I wish for it start from Row 2 (to exclude the line showing the file path), would this possible?

      Many thanks

Resources