How to use VBA code to implement automatic daily backup of Excel documents
To achieve this "tall yet" features existing Excel features cannot be completed, but also the method of VBA programming. Of course, as you do not understand the VBA code, just follow the steps below to copy and paste.
Step 1th: Open the Excel file you want to back up, right-click on the worksheet tab, and click "View Code".
The 2nd step is to open a VisualBasic window, double-click the ThisWorkbook in the Project window, and paste the following code into the right-hand window.
Code:
Private Sub workbook_beforeclose (Cancel as Boolean)
On Error Resume Next
Dim MyPath As String, fname as String
fname = Format (Date, "YYMMDD") & Thisworkbook.name
MyPath = Thisworkbook.path & "/Backup/"
Thisworkbook.savecopyas MyPath & fname
End Sub
3rd Step: Click the Save command in the Visual Basic window to pop up the prompt to save the macros, and then click the "No" button.
In the Save window that pops up, choose Save Workbook with Excel enabled macros.
4th step: In the current folder, create a new folder named Backup.