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.
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.
Learn more about Allen...
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.
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.
Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!