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: Newest
  1. Anonymous
    2014-06-26T19:50:50+00:00

    I am trying to use the vba code below as well:

    Function LastSaveDate()

        Application.Volatile True

        LastSaveDate = FileDateTime(ThisWorkbook.FullName)

    End Function

    You can call this from a cell with

    =LastSaveDate()

    and I keep getting a #NAME? error whenever I put =LastSaveDate() into the cell that I want the timestamp to be.

    Anybody know why this is occurring?

    Well, over a year later, but I think I have an answer...

    I was copy/pasting the =LastSaveDate() into the cell and got the same #NAME? result. When I hand-typed it in, it worked. I don't know if that's a universal solution or I just tried it enough and Excel finally conceded defeat. Worth a shot though...

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2014-06-16T18:58:28+00:00

    Well written. Thanks!

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2014-05-29T14:48:18+00:00

    Chip, I'm actually very well-versed in Excel and have functional knowledge of VBA, but as someone who supports the "average user" every day I'm always frustrated that the first answer to most questions involves code.  

    For the vast majority of Excel users, writing a macro is NOT "simple."  I coach dozens of intelligent, educated engineers (the kind who take licensing exams and design roads, pipes, and buildings, not programmers) who barely understand anything beyond use of simple arithmetic formulas.  Functions like SUBTOTAL and SUMPRODUCT are viewed with suspicion; they turn pale if you say "macro" or "visual basic."  

    The average user not only cannot write code, their installation security blocks macros and they are warned over and over NOT to disable that protection.  VBA simply is not an option for users in many network environments.  

    Please, tell MVPs and other support offerors - THE SIMPLEST SOLUTION IS OFTEN THE BEST.  Simple means something I can do within the Excel environment as it opens "out of the box" without activating the Developer ribbon (there's a reason it isn't in the default setup!) or opening a secondary program (Visual Basic Editor).  

    I don't apologize for the rant - it needs to be said - but I'm sorry it's aimed specifically at one MVP, you're just the one I can reach at the moment.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2014-04-09T19:36:04+00:00

    Thanks for your suggestion....but it doesn't solve this problem.

    A lot of people are looking for an option to include the last date and time the file was revised on print-outs. (Different print dates don't indicate whether print-outs are identical or if there have been changes.)

    While your description correctly describes the situation when viewing a file on-screen, upon printing an Excel workbook, the date/time functions automatically update. So, the feature you described will always indicate the date it was printed. Note: after printing, the date/time displayed on-screen has changed. Consistent with what you wrote, if you don't save the file, the next time you open it, the date/time will have reverted back again.

    Interestingly, Word  has a feature for users to prevent fields from updating when the document  is printed. Excel does not seem  to have an equivalent feature.

    This overlooked functionality is made more frustrating because Excel has a direct feature for users to view the document properties...but on-screen viewing is as far as the user interface provides.

    Was this answer helpful?

    0 comments No comments