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-01-15T19:16:46+00:00

    GP2,

    I found a site that gave me the Modified date that I was looking for. Dinesh fix seemed to work for others, but unfortunately I could not get the #NAME? error to go away. Here is the link to the site:

    http://www.extendoffice.com/documents/excel/954-excel-created-last-modified-time.html I used VBA 2 and it worked. I hope this works for you.

    Maria

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2014-01-12T05:48:10+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

    I too was surprised to not find this functionality anywhere in Excel.

    This has been available in MS Word for years, and I definetly agree, it should be standard in Excel. After looking through every menu option (some more than once), i gave up then looked online. This is where I found your posted question and and the replies to it.

    I found many posts for this issue along with several replies, and yes, it seems like many feel this should be a built-in fucntion. There seemed to be several replies that were not helpful, along with a couple smart-**** answers.

    So would like to add to this.... by complimenting whetstonejon for his reply. It seems well written and extremely helpful. I'm not extremely familar with Excel, but maybe this user function (and any similar) can be maintained, in a common 'library' that any spreadsheet could access and use the functions, but that's for another post.

    Thank you again for your question and for the reply from whetstonejon.

    Also, thank you for your follow up about the Macro setting, that would have gave me a problem as well.

    Pete

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2014-01-12T05:01:09+00:00

    >>>

    As far as I know, the only way to get the saved date is via some non-simple vba macro that must be inserted into your worksheet

    <<<

     

    It isn't "non-simple" at all. It is quite simple, just two lines of code.

     

     

    Function LastSaveDate()

        Application.Volatile True

        LastSaveDate = FileDateTime(ThisWorkbook.FullName)

    End Function

     

    You can call this from a cell with

    =LastSaveDate()

     

    That's your perspective as an MVP and VBA expert (and probably other programming languages too). The average user like me does not want to write a line of code to use a very basic function for many reasons especially when that function has existed in other parts of Microsoft office for many, many years. Is it so hard for the same product team in the same company to share the code and get basic functionality consistent among the sub-products?

     

    Besides, you are also ignoring another major issue which is our deployment of excel disables macros by default. While this may be trivial to you technically ("just" 2-lines of code as you put it), will still require the same painful, lengthy approval process to get through the IT department.

     

    Try to consider the perspective of the average excel user who has little control over the software installed on her computer and really doesn't know even where to start writing a macro program.

    Even though this is a year-old post, I just ran into the same problem and looking for a reference to a solution.    I agree with your reply to Mr. Peason post 100%.  I read it and thought the exact same thing, how condescending he is.  I actually type a reply similar to yours, forgot to click Submit, came back later and happen to read your email.  I cancelled that reply and reply to your post, again well written and I agree 100%.  We are still using Excel 2010, maybe one of the newer version's does include the same functionality as in Word!

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2013-12-31T10:27:34+00:00

    Hi all, it will be useful to add some error management steps.

    i.e. if you put this function in a template, the property is not defined when you create a new one until it will be saved for the first time.

    I suggest these :

    Private Function LastSave()

    Application.Volatile

    LastSave = ""

    On Error Resume Next

    LastSave = ThisWorkbook.BuiltinDocumentProperties("Last Save Time").Value

    ' In a cell enter: =lastsave()

    ' This macro must be stored in a module; not in a sheet

    End Function

    Was this answer helpful?

    0 comments No comments