Ankur Kumar
New Member
Hi all,
I have a vba code which automatically take backup of workbook in different location but i am looking a code which automatically deleted older file of workbook from that folder and rest remain in that folder.
here is my code
Thanks!
Ankur
I have a vba code which automatically take backup of workbook in different location but i am looking a code which automatically deleted older file of workbook from that folder and rest remain in that folder.
here is my code
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.DisplayAlerts = False
Dim backupfolder As String
backupfolder = "D:\Auto Backup Sales Detail\Closed\"
ThisWorkbook.SaveCopyAs Filename:=backupfolder & " " & Format(Now, "dd-mmm-yy h-mm-ss") & " " & ActiveWorkbook.Name
ThisWorkbook.Save
Application.DisplayAlerts = True
End Sub
Thanks!
Ankur
Last edited by a moderator: