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
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:
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.
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!
Do your macros seem to be disabled on your new machine? It could be because of the security settings in Excel. Here's ...
Discover MoreNeed to know how many characters there are in a workbook? You can find out easily with the handy macro introduced in this ...
Discover MoreYou can, from within your macros, easily display a message box containing a message of your choice. If you want to ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments