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
    2013-03-08T20:15:21+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?

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-03-08T13:02:08+00:00

    I did the same thin as Chip Pearson suggested but I got #NAME? error when i typed =LastSaveDate()   in A1.

    any help??

    Was 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-02-27T17:19:46+00:00

    This works great with local files, but I tried getting the FileDateTime from a file on a SharePoint site in my company and it failed with "Invalid procedure call or argument".

    Any other suggestions?

    Was this answer helpful?

    0 comments No comments