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, Excel in Microsoft 365, and 2021


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, Excel in Microsoft 365, and 2021.

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

Finding the Smallest Even Value

When processing data in a worksheet, you may have a need to know what the smallest (lowest) even value in a range is. You ...

Discover More

Page Layout Zoom Settings

The zoom setting at which you view a document can sometimes be saved with a document. This tip explains how the zoom ...

Discover More

Saving Changes when Closing

If your macro closes workbooks, you'll want to make sure that it will save any changes you made to the workbook. Here's ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Exiting a For ... Next Loop Early

If you use For ... Next loops in your macros, make sure you give a way to jump out of the loop early. That way you can ...

Discover More

Opening a Workbook but Disabling Macros

Macros that run automatically when you open or close a workbook are quite helpful. You may not want them to run, however, ...

Discover More

Specifying Location for a Message Box

When writing macros, you may want to position a message box at a specific location on the screen. This can't be done in ...

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 2 + 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.