Written by Allen Wyatt (last updated August 10, 2024)
This tip applies to Excel 97, 2000, 2002, and 2003
As part of setting up a worksheet, you may want the header or footer to contain the date that the workbook was last edited. Excel doesn't maintain this information, but it does allow you to perform macros whenever certain events occur, such as changes to a workbook. All you need to do is add a macro such as the following to the ThisWorkbook object in the VBA Editor:
Private Sub Workbook_SheetChange(ByVal _ Sh As Object, ByVal Target As Excel.Range) ActiveSheet.PageSetup.CenterFooter = _ "Worksheet Last Changed: " & _ Format(Now, "mmmm d, yyyy hh:mm") End Sub
The macro results in each footer on each worksheet in the workbook having separate dates and times on them, since each worksheet would be updated at different times. You can change the destination property (.CenterFooter) to one of the other header or footer properties (.LeftHeader, .CenterHeader, .RightHeader, .LeftFooter, .RightFooter) as desired.
You may want the header or footer to instead include the date that the workbook was last saved. (This is what many people really view as the "last edit date.") The information is visible in the Properties dialog box for a worksheet, but Excel has no menu selection or other command that allows you to insert this date into a header or footer. Instead, you must use a macro to add the desired information.
The best way to accomplish the task is to add a macro to the ThisWorkbook object that is triggered just before a workbook is saved:
Private Sub Workbook_BeforeSave(ByVal _ SaveAsUI As Boolean, Cancel As Boolean) Dim sht For Each sht In Sheets sht.PageSetup.CenterFooter = _ "Workbook Last Saved: " & _ Format(Now, "mmmm d, yyyy hh:mm") Next End Sub
This macro steps through each worksheet in the workbook and changes every center footer to have the date that the workbook was saved.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3352) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Date Last Edited.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
Using a macro to add the full path name into a header or footer in an Excel worksheet.
Discover MoreWant to add some color to the printing of your page headers and footers? Your options are limited, as disclosed in this tip.
Discover MoreWhen printing a worksheet, you may want to have the footer different on the first page of your document than it is on ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon 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