Insert the date an Excel Workbook was last modified.

Anonymous
2010-11-17T00:13:29+00:00

Is there a way to insert, into a cell, the date that a workbook was last modified?

Perhaps by getting the modified date from the file's properties into a cell.

Thanks in advance.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
Anonymous
2010-11-17T00:29:39+00:00

Hi,

To modify a workbook you have to save it so we can use the before_save event

ALY+F11 to open vb editor. Double click 'ThisWorkbook' and paste this code in on the right. Change the sheet and range to suit

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

Sheets("Sheet1").Range("A1").Value = Now

End Sub


If this post answers your question, please mark it as the Answer.

Mike H

Was this answer helpful?

100+ people found this answer helpful.
0 comments No comments

86 additional answers

Sort by: Most helpful
  1. Anonymous
    2013-10-21T16:56:02+00:00

    I believe you missed to type the opening and closing brackets after LastSaveDate.

    It should be

      = LastSaveDate()

    I tried without the brackets and it showed me the error as your stated (#Name? error). Please try with the brackets.

    More over I'm trying with older version of excel. Hope it works in the recent versions also.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-10-21T12:52:36+00:00

    Thanks, Dinesh, for the detailed instructions, but it did not work for me (using Excel 2010). I copied your code into the new "Module 1" under "Modules", saved the Excel file from within the VB window (I assume that is what you mean by "Save this file"?), then did "File, Close and Return to Microsoft Excel". When I start typing "= LastSaveDate" into a cell, the text populates automatically with the full LastSaveDate name (so it is present), but after I've hit Return the #NAME? error appears in the cell.

    Does anyone have any ideas where I'm going wrong?

    Just to agree with others, this is a very useful function that should be a standard function in Excel.

    Jon K

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2013-10-11T14:55:35+00:00

    Thanks Dinesh, worked great.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2013-06-20T00:28:55+00:00

    Perhaps someone could post a snippet of the code as it appears in the VB script window. It took me a few tries to get this to work, but it made sense after it got working. I have the code in an Excel template, and just cut & paste the data when I need it in another file.

    I would post a snip of my file, but do not know how to upload graphics here (or if it is even possible).

    With all that said, it is RIDICULOUS that Microsoft doesn't offer this as part of an Office upgrade. God knows we get enough updates to Office every month, as part of Windows updates.

    Was this answer helpful?

    0 comments No comments