Written by Allen Wyatt (last updated April 1, 2021)
This tip applies to Excel 97, 2000, 2002, and 2003
There may be times when you want your header or footer to contain the date of the last time that your workbook was saved. Normally, this is not information you can set in Excel. However, you can use the following macro to force the information into the proper place:
Sub MyFooter() Dim mh As String On Error Resume Next mh = ActiveWorkbook.BuiltinDocumentProperties("Last Save Time") If Err = 440 Then Err = 0 mh = ActiveWorkbook.BuiltinDocumentProperties("Creation Date") If Err = 440 Then Err = 0 mh = "Not Set" End If End If mh = Left(mh, 8) ActiveSheet.PageSetup.LeftFooter = "Saved: " & mh End Sub
There are a number of items to note in this macro. First of all, it attempts to determine the last date (and time) that the workbook was saved. If that information cannot be determined, then it extracts the date it was created. Finally, if that cannot be found, then it sets the footer to "Not Saved."
Notice that there is some error handling done in this macro. The reason is that Excel will return an error if a particular document property (BuiltinDocumentProperty in this case) is not set. The error needs to be intercepted and handled, which is done here.
You should note that this macro, once run, will set the left footer to the desired information. That information will not change again until you run the macro again. Thus, if you always want an up-to-date date in the footer, then you should either run the macro periodically (perhaps right before printing), or set it up to run whenever you open your document.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2055) applies to Microsoft Excel 97, 2000, 2002, and 2003.
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!
Applying color to the text in your headers and footers is a bit of a dream in some versions of Excel. Here's an overview ...
Discover MoreWhen creating headers and footers in an Excel worksheet, you can use special codes to add or format information. 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 © 2024 Sharon Parq Associates, Inc.
Comments