PDA

View Full Version : update date automatically hen saved



msahmed
09-16-2016, 11:14 AM
hi there,

I am struck across a macro where i need the cell "B2" of "Sheet1" to be updated with the current date in mm.dd.yyyy format only when we save the sheet

Thanx in advance

mana
09-16-2016, 04:39 PM
ThisWorkbook module


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If ThisWorkbook.Saved = False Then
ThisWorkbook.Worksheets("Sheet1").Range("B2").Value = Date
End If
End Sub

msahmed
09-19-2016, 07:40 AM
I guess it's not working...:think:

Aussiebear
09-19-2016, 04:24 PM
I guess it's not working...:think:

What is that supposed to mean to us? You need to understand that:

1. We cant see your workbook because you didn't attach one to review,
2. We are unable to review your code as you didn't post any,
3. You then post a completely irrelevant statement such as "I guess its not working".

Since you are asking for assistance, try the following:

1. Post your workbook, with the relevant section of code that is failing,
2. Indicate which line/s the code errors out on,
3. List any error messages you are seeing.