What's incorrect with this? And also, how can I modify the date & time formatting, or where can I learn how to do that?
Thank you so much,
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 archive this file?" ans = MsgBox(Msg, vbYesNo) If ans = vbYes Then ThisWorkbook.SaveAs Filename:="C:Backup" & MonthName(MyMonth) & "-" & Day(Date) & "-" & Year(Date) & "-" & ThisWorkbook.Name End If End Sub
VB:Now when I try to run the macro, it gives me an error saying: Compile Error, Wrong number of arguments or invalid property assignment. And it highlights "format" in yellow.ActiveWorkbook.SaveAs Filename:="C:FinalOutput.xls " & _ format(Now(), "mm_dd_yyyy hh mm AMPM"), FileFormat:=xlNormal, Password:="", _ WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=FalseIf you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
VB:Please see the attachment for the example. What I need is whenever row 3 ="x" I need the corresponding cell in row "d" to update with the latest date, time and username. Please not the macro is currently not active on the sheet as i've added the ' character. Please remove this when you take a look.Range) If Not Intersect(Range("B2:BZ2"), Target) Is Nothing Then Range("C" & Target.Column).Value = Format(Date, "dd-mmm") & " " & Format(Time, "hh:mm") & " by " & (Application.UserName) End If End SubIf you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines