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
    2016-10-04T03:41:09+00:00

    Thank you for this response. It seems to work...on my work computer. When I try it on my personal computer at home, I keep getting an MVB Run-time error '28': Out of stack space. If it debug it or end it, it kicks me out of MS Excel. Why would I have this problem with my home computer and not my work computer?

    James

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2016-10-03T20:16:24+00:00

    Thank you!  I really appreciate it!

    Orlando

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2016-10-02T15:32:54+00:00

    I believe this is the macro you are referring to:

    Function LastSaveDate()

        Application.Volatile True

        LastSaveDate = FileDateTime(ThisWorkbook.FullName)

    End Function

    Where it says Thisworkbook.FullName, you can replace that with any fully qualified filename. 

    so if you have a txt file named Mytextfile.txt  in C:\Myfolder\Mysubfolder  you could do

    Function LastSaveDate()

        Application.Volatile True

        LastSaveDate = FileDateTime("C:\Myfolder\Mysubfolder\mytextfile.txt")

    End Function

    --

    Regards,

    Tom Ogilvy

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2016-09-30T13:20:28+00:00

    Hi Chip,

    This is very simple and works great.  Quick q for you....is there a way to modify this to see the FileDateTime data for another file, a text file, or xlsx, etc. other than the current workbook?

    Thank you!

    Orlando

    Was this answer helpful?

    0 comments No comments