Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Date Last Edited.
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.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
Using a macro to add the full path name into a header or footer in an Excel worksheet.
Discover MoreDo you want to change the headers and footers that appear on different pages of your printout? Here's how you can get ...
Discover MoreSetting up a single footer line for your printouts is fairly easy. If you want to move part of the footer down a line so ...
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 © 2024 Sharon Parq Associates, Inc.
Comments