Macro to Auto Save File Periodically

skf786

Board Regular
Joined
Sep 26, 2010
Messages
156
Hello,

im looking for a macro to auto save my file 'xyz' as a backup on the 1st and 15th of each month. backup file name shall be xyz-backup-dd-mm-yyyy and it shall be saved in the same folder where the original file is saved.

Many thanks

kf
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Try:
(into ThisWorkBook code)

Excel Formula:
Private Sub Workbook_Open()
mfile = Split(ThisWorkbook.Name, ".")
backupFile = ThisWorkbook.Path & "\" & mfile(0) & "-backup-" & Format(Now, "dd-mm-yyyy") & "." & mfile(1)
If Day(Now) = 1 Or Day(Now) = 15 Then
    ThisWorkbook.SaveCopyAs backupFile
End If
End Sub
 
Upvote 0
Try:
(into ThisWorkBook code)

Excel Formula:
Private Sub Workbook_Open()
mfile = Split(ThisWorkbook.Name, ".")
backupFile = ThisWorkbook.Path & "\" & mfile(0) & "-backup-" & Format(Now, "dd-mm-yyyy") & "." & mfile(1)
If Day(Now) = 1 Or Day(Now) = 15 Then
    ThisWorkbook.SaveCopyAs backupFile
End If
End Sub
that is an awesome code :) thank you so much.

have a nice day

KF
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,547
Members
449,089
Latest member
davidcom

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