May 03 2021 05:38 PM - edited May 03 2021 06:48 PM
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
May 04 2021 03:35 AM
SolutionChange 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
May 04 2021 05:26 PM
May 05 2021 02:53 AM
May 06 2021 04:24 PM - edited May 06 2021 04:24 PM
Hi @hans,
Thanks for your reply.
I have tried to update this, however then i get the below error when i run the macro.
Unfortunately i am not sure about this error.
Thanks for your help, much appreciated.
May 07 2021 02:20 AM
Change the lines
'Copying data to new sheet
destinationSheet.Range(destinationSheet.Cells(1, sourceStartCol), destinationSheet.Cells(sourceEndRow - sourceStartRow, sourceEndCol)).Value = sourceSheet.Range(sourceSheet.Cells(sourceStartRow, sourceStartCol), sourceSheet.Cells(sourceEndRow, sourceEndCol)).Value
to
'Copying data to new sheet
destinationSheet.Range(destinationSheet.Cells(1, sourceStartCol), destinationSheet.Cells(sourceEndRow - sourceStartRow + 1, sourceEndCol)).Value = sourceSheet.Range(sourceSheet.Cells(sourceStartRow, sourceStartCol), sourceSheet.Cells(sourceEndRow, sourceEndCol)).Value
May 04 2021 03:35 AM
SolutionChange 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