Automaticly Back-up file each month or week

TimvMechelen

Board Regular
Joined
Nov 7, 2016
Messages
121
Hi,

I'm searching for a VBA code that saves my workbook (.xlsm file) every first day of the month, or every first day of the week (while opening).

Can somebody help me with this problem?

Thank you.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Something like this?

Place the code in the ThisWorkbook module of your desired workbook. This will make a backup every Monday and on the first of each month. The backup will be in the same folder as the source file and will be in the format of "filename.extension_20161205_1041.bak" where the numbers are year|month|day_hour|minute. You can change the timestamp scheme to suit.

hth

Dr. D


Code:
Private Sub Workbook_Open()
  ' ~~ Run on Mondays || [URL="http://www.ozgrid.com/forum/showthread.php?t=27427#4"]if today is Monday(weekday)[/URL]
  If Weekday(Now) = (vbMonday) Or Day(Now) = 1 Then
    With ActiveWorkbook
      .SaveCopyAs .FullName & Format(Now, "_yyyymmdd_hhmm.bak")
      .Save
    End With
  End If
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,535
Messages
6,114,194
Members
448,554
Latest member
Gleisner2

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