Save Backup Workbook With Macro

Twollaston

Board Regular
Joined
May 24, 2019
Messages
241
Hello there,

I'm trying to find a macro that I can add to my quick access toolbar to be able to save the file as, with the current file name and the date and time added.
to this path
C:\Users\wwollaston\Documents\Files\Backups\


For Example,

I'm in a workbook named Workbook1 and I run the macro, now I should have a file saved here
C:\Users\wwollaston\Documents\Files\Backups\Workbook1 8.6.2019 3:32PM.xlsx
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Does this work? You can't have : in a file name, so the time is separated by a period.

Code:
Sub Backup()
Dim path As String: path = "C:\Users\wwollaston\Documents\Files\Backups\"
ThisWorkbook.SaveAs path & "Workbook1 " & Format(Now(), "m.d.yyyy h.nn am/pm") & ".xlsm", xlOpenXMLWorkbookMacroEnabled
End Sub
 
Upvote 0
Hey thanks a lot for helping me lrobbo, your code helped me find exactly how to do what I wanted!
 
Upvote 0
great I'm glad it's helping out.
 
Upvote 0

Forum statistics

Threads
1,214,984
Messages
6,122,601
Members
449,089
Latest member
Motoracer88

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