Putting the Last Saved Date in a Cell

Written by Allen Wyatt (last updated June 22, 2024)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365


1

Kimberly wonders if there is a formula she can use to put into a cell the date the workbook was last saved. Even if she opens the workbook every day, she only wants the date updated every time she chooses to save.

There is no formula to do this; Excel doesn't have the native capability. You can, however, create a simple macro that will stick a date value into a cell whenever you save the workbook. This is based on the BeforeSave event, which belongs to the ThisWorkbook object:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
  Cancel As Boolean)

    Sheets(1).Range("A1").Value = Now()
End Sub

This macro places the date (actually, the value returned by the Now function) into cell A1 of the first worksheet in the workbook. That cell should be formatted within Excel to whatever format you desire. There is a potential drawback to this macro—if you use Save As (to save the workbook under a different name) and then choose to cancel the save, the date is still updated because it took place before the save—meaning, it took place just as Excel was starting to save the workbook, not after the workbook was actually saved.

It should be noted that Excel also includes an AfterSave event which you may be tempted to use to update information. It, unfortunately, has a few loopholes, as well, and offers nothing more foolproof than the BeforeSave event does.

If you prefer, you can use a slightly different macro-based approach. This one relies on a regular macro, not an event handler:

Function LastModified() As Date
    Application.Volatile
    LastModified = ThisWorkbook.BuiltinDocumentProperties("Last Save Time")
End Function

Within whatever cell you want the date to appear, you would call the macro in this way:

=LastModified()

The formula returns the date and time the workbook was last saved, and you can format it in any way desired. Since the function is noted as volatile, it is updated continuously, whenever the worksheet is recalculated.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13575) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Cannot Add Words to Dictionary

We all run across words that are spelled correctly, but that Word isn't aware of. The solution is to add those words to ...

Discover More

Determining the Length of a Non-Document Text File

If you use a macro to create and work with text files, you can find out the length of those files using a simple command. ...

Discover More

Shortcut to Merge Cells

Need to merge a bunch of cells together on a regular basis? You'll love the two macros in this tip which can make short ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Disabled Macros

Do your macros seem to be disabled on your new machine? It could be because of the security settings in Excel. Here's ...

Discover More

Counting All Characters

Need to know how many characters there are in a workbook? You can find out easily with the handy macro introduced in this ...

Discover More

Conditionally Displaying a Message Box

You can, from within your macros, easily display a message box containing a message of your choice. If you want to ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two more than 2?

2024-06-22 14:27:41

J. Woolley

Here are two ways to get the active workbook's last modified (saved) date and time using functions available in My Excel Toolbox:
    =GetDocProperty("Last Save Time") -- returns date and time as text
    =FileLastDate() -- returns a numeric date/time serial value
The general syntax of those functions follows:
    =GetDocProperty(Name, [Approx])
Name is the built-in or custom workbook document property requested (case ignored). If optional Approx is FALSE (default), then Name is explicit; otherwise, the first document property containing Name will be returned.
    =FileLastDate([FilePath])
FilePath is optional; default is the active workbook. If FilePath is not absolute (like "C:\Users\MyName\Documents\MyFile.xlsx") or is not found, then it is relative to the active workbook's folder (like "MyFile.xlsx"
or ".\SubFolder\MyFile.xlsx" or "..\SiblingFolder\MyFile.xlsx").
See https://sites.google.com/view/MyExcelToolbox
For related discussion, see the following Tips:
https://excelribbon.tips.net/T011604_Date_Last_Edited.html
https://excelribbon.tips.net/T007764_Displaying_the_Last_Modified_Date.html
https://excelribbon.tips.net/T011099_Last_Saved_Date_in_a_Footer.html


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.