Automate Backup of Current File Quickly

How to automate backup of current file quickly and easily with VBA. Many times we wish to work with our current data using a new macro. If we are not 100% confident what exact action the macro will do and are doubtful about losing our precious data then it’s a good idea to backup the file or save a copy of that file. Watch the video to learn how the process of backup is automated with VBA:

Watch this video on YouTube.

Here’s the complete VBA code to automate the backup of the file currently in use:

Sub fileBackUp()
MsgBox ThisWorkbook.Path
Dim reply As Integer
reply = MsgBox(“Want to take a backup?”, vbYesNo)
If reply = vbYes Then
ThisWorkbook.SaveCopyAs Filename:=ThisWorkbook.Path & “\” & Format(Date, “mm-dd-yyyy”) & “_” & ThisWorkbook.Name
End If
End Sub

Sample file for download and practice: