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

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
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,215,459
Messages
6,124,944
Members
449,198
Latest member
MhammadishaqKhan

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