VBA code to backup Workbook everyhour

Dhungana

New Member
Joined
Apr 7, 2019
Messages
1
Hi,
Can anyone help me with quick and simple VBA code to backup excel file everyhour in different folder. This way I will have a backup file for my tracker which is shared to different users.

Thank you
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Note: To save the file every hour you need a macro that is latent, but that will make your sheet slower.

To start, run the "Start" macro. If you want to stop the execution, execute the "Finish" macro

The book will be saved every hour in a different folder, if it is 8am in the folder where you have the book and \08 folder; if it is 3pm in a folder where you have your book and \15 folder.

Code:
Dim actual


Sub Backup_everyhour()
   Dim wPath As String
   wPath = ThisWorkbook.Path & "\" & Format(Now(), "hh") & "\"
   ThisWorkbook.SaveCopyAs wPath & ThisWorkbook.Name & ".xlsm"
   actual = Now
   Application.OnTime earliesttime:=actual + TimeValue("01:00:00"), Procedure:="Backup_everyhour", schedule:=True
End Sub


Sub start()
   Call Backup_everyhour
End Sub


Sub finish()
   On Error Resume Next
   Application.OnTime earliesttime:=actual + TimeValue("00:00:05"), Procedure:="Backup_everyhour", schedule:=[COLOR=#0000ff]False[/COLOR]
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

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