"last saved" date and hour of a file in a cell of the worksheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to see the "last saved" date and hour of a file in a cell of the worksheet of the file.
I try to find a solution for a long time without succes.
thanks in advance for your help
Rey
 
Paste this in 'Workbook' entered VBA code:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean,
Cancel As Boolean)
Worksheets("Sheet1").Range("A1").Value = Now()
End Sub

HTH
GerryK
-----Original Message-----
Is it possible to see the "last saved" date and hour of a
file in a cell of the worksheet of the file.
 
The NOW() function updates each time the ws recalculates and is probably not
want the OP wanted. DATE is a static value.
 
Hi Jim!

I think you are confusing what GerryK has suggested with the NOW
function. GerryK's approach does not put NOW() in A1 it puts the date
and time there.

If you try out Gerry's code, you'll see that it inserts date and time
into the cell and that workbook recalculation has no impact upon it.
Saving the workbook updates A1, which I think is what OP wanted.

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
You might try this as well,

In VBA code put:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean,
Cancel As Boolean)
ThisWorkbook.Names.Add Name:="LastSaved", _
RefersToR1C1:="=""" & _
Format(Now, "dd-mmm-yy hh:mm") & """"
End Sub

In A1 put =LastSaved
Last Saved = Yes, then the date changes.

HTH
Gerry

-----Original Message-----
Is it possible to see the "last saved" date and hour of a
file in a cell of the worksheet of the file.
 
Thank you but I don't know where to write these code. I never use the macros in excel.
I found also another solution. But with the same problem: where do I have to write these codes.
thanks
Rey


Function LastSaved()
On Error GoTo FunctionErr

Application.Volatile
LastSaved = ActiveWorkbook.BuiltinDocumentProperties("Last Save Time").Value
Exit Function

FunctionErr:
LastSaved = "File not saved"

End Function
 
Press Alt and F11 then paste code in This Workbook (you
see it on the left hand side).
(make sure the code lines are 'in line' and not displayed
in red!)

Alt + F11 again and you are out into your spread sheet.
HTH
-----Original Message-----
Thank you but I don't know where to write these code. I never use the macros in excel.
I found also another solution. But with the same problem:
where do I have to write these codes.
 
Back
Top