Hi,
I am trying to write macro for backup of excel sheet, but while executing the macro its giving the error.
"Sub Macro1()
'
' Macro1 Macro
'
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim Msg As String
Dim ans As Integer
Dim fname As String
Dim MyDate
Dim MyMonth
MyDate = Date
MyMonth = Month(MyDate)
Msg = "Would you like to back up file?"
ans = MsgBox(Msg, vbYesNo)
If ans = vbYes Then
ThisWorkbook.SaveAs Filename:="D:\Backup\" & MonthName(MyMonth) & "-" & Day(Date) & "-" & Year(Date) & "-" & ThisWorkbook.Name
End If
'
End Sub"
Bookmarks