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-04-05T13:11:35+00:00

    I had the same problem, but Dave_A_NM actually sketched a solution above. The macro has to be in a module and a quick way of creating a module is like this:

    Start the macro recorder and stop it again

    ALT+F11

    In the left column of the visual basic window find Modules with Module 1

    Double Click on Module 1

    Delete the newly created Macro1 () in the text field to the right

    Insert the LastSaveDate() macro text in stead

    My macro is a little different, but it works:

    Private Function LastSave()

        Application.Volatile

        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

    Now I only need to find out how to define the correct format, when entering this

    ="Last saved: "&lastsave()

    but that is a smal problem

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2013-03-23T16:17:28+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.

    Well - I have to second this sentiment. I am a Program Manager that would find it very helpful to know when my task sheets were last saved. I am not "into programming", although I do not mind dabbling with macros and other Excel functions. I have spent the last hour trying to figure out VBA ..... simply to add a date to a spreadsheet. 

    The comment above "It isn't non-simple at all. It is quite simple, just two lines of code" borders on being condescending. It is comparable to saying "making a million dollars isn't non-simple at all. It is quite simple, just earn it".

    This is like driving a tack with a sledgehammer.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  3. Anonymous
    2013-03-07T15:18:33+00:00

    This worked for me once I figured out where to put the function.  Here's the article that explained that piece: http://www.exceldigest.com/myblog/2011/04/23/how-to-create-a-user-defined-function-in-excel-2007-or-excel-2010/.  I had tried the approach in the original article (get into Visual Basic and double click "ThisWorkbook" and entered the function there), but Excel wouldn't recognize the function.  The linked article says to get into Visual Basic and go to Insert -> Module,  then enter the function in the Module.  That worked.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  4. Anonymous
    2013-01-18T17:30:34+00:00

    Inserting the date a file was last saved is a pretty common need for a project team that's using the same document. I think it's not very user friendly to require programming ability to insert the date a file was last saved. I'm using Excel 2010 and see that there's a button to insert "date" on the footer. I'm not sure what "date" it's referring to but hope it's the save date.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments