VBA saving file with unique name

BrianG86

Board Regular
Joined
Nov 12, 2013
Messages
135
Hi,

I have a code that performs a task for me and will save the file at the end. It currently saves as a name I have selected and today's date. The problem I now face is that I will be completing this task several times a day and it will not work as the file names will be the same. Is there any way to save a unique name each time?

My code to save below:

Code:
ActiveWorkbook.SaveAs Filename:= _        "T:\Lender Updates\Lender Updates\Lloyds\Complete\Acknowledged " & Format(Date, "dd.mm.yyyy") & ".xlsm", _
        FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Try like this

Code:
ActiveWorkbook.SaveAs Filename:="T:\Lender Updates\Lender Updates\Lloyds\Complete\Acknowledged " & Format(Now, "dd.mm.yyyy hhmmss") & ".xlsm", _
        FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
 
Upvote 0
Thanks for this, it works well.

Is there a way to save it with a different reference each time though? So if the last file saved was 0001, then the next file should be 0002?

Thanks
 
Upvote 0
Is anyone able to help here? I would like the file names to be saved with a unique reference that will go up one number at a time, so L001, next L002?

Thanks
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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