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: Last Saved Date in a Footer.

Last Saved Date in a Footer

Written by Allen Wyatt (last updated March 16, 2024)
This tip applies to Excel 97, 2000, 2002, and 2003


Lori wants the right side of the footer for her worksheet to include the date the workbook was last saved. Every time she tries to create a formula to do this, Excel displays an error message that states the "string is too long" and that she needs to delete some characters. She's not sure she understands why this is happening or how she can get the date she wants in the footer.

There is no actual formula that can put the last-saved date in a footer. Excel has no way (unlike Word) to put this tidbit of information there. There is a way you can do it, but the solution requires the use of a macro. The reason is because you are accessing system information—information outside of Excel itself—and that information can only be retrieved using a programming language such as VBA.

One approach is to add some code that runs whenever a workbook is saved. The code would update the desired footer with the current date:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
  Cancel As Boolean)

    ActiveWorksheet.PageSetup.RightFooter = _
      "Last Saved: " & Format(Date, "mmmm d, yyyy")
End Sub

This macro, which should be stored in the ThisWorkbook object for the workbook you want to affect, updates the footer for the currently active worksheet. If you want to affect all the worksheets in a workbook, then a small change to the macro is in order:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
  Cancel As Boolean)
    Dim sht As Worksheet

    For Each sht In Sheets
        sht.PageSetup.RightFooter = _
          "Last Saved: " & Format(Date, "mmmm d, yyyy")
    Next
End Sub

If today is December 12, 2011, then after running the macro (which is done automatically when saving), the right footers will all be set to "Last Saved: December 12, 2011".

You can also rely upon the file save date stored in Excel's built-in properties. The way you put that date into the footer is as follows:

Sub RightFooterLastSaved()
     ActiveSheet.PageSetup.RightFooter = _
       ActiveWorkbook.BuiltinDocumentProperties(12)
End Sub

The drawback to this macro is that you need to remember to run it periodically, so it is not quite as automatic as the previous approaches. You could, however, place the single line at the heart of the macro into the Workbook_BeforePrint event handler.

There is another approach you can use. This one involves requesting from Windows the actual date and time a file was saved.

Private Sub Workbook_Open()
    Dim sTemp As String
    Dim sht As Worksheet

    sTemp = FileDateTime(ActiveWorkbook.FullName)
    sTemp = "Last Saved: " & sTemp
    For Each sht In Sheets
        sht.PageSetup.RightFooter = sTemp
    Next sht
End Sub

This macro is designed to run whenever a workbook is first opened—it is saved as the Workbook_Open procedure of the ThisWorkbook object. The workhorse of the macro is the line that calls the FileDateTime function. This function can be used to determine the date and time any file was saved. It requires a full path name of a file, which is supplied by the FullName property of the ActiveWorkbook object. This date and time is then placed in the right footer of all the worksheets in the workbook.

Remember, as well, that the limit of what you can place into each section of the header or footer is approximately 250 characters. So if you adjust the macros to add more information to the right portion of the footer, make sure that it doesn't add up to that many characters, or you may have problems with the macro.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2190) 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: Last Saved Date in a Footer.

Author Bio

Allen Wyatt

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. ...

MORE FROM ALLEN

Locating Locked Fields

A field can be locked or unlocked, and its condition controls whether it is updated automatically or not. If you want to ...

Discover More

Creating Usable Figure Captions

Many people add both images and figure captions within text boxes so they can be easily positioned within a document. ...

Discover More

Moving and Copying Cells

At the very heart of editing is the ability to move and copy cells in a worksheet. Understanding the differences between ...

Discover More

Dive Deep into Macros! Make Excel do things you thought were impossible, discover techniques you won't find anywhere else, and create powerful automated reports. Bill Jelen and Tracy Syrstad help you instantly visualize information to make it actionable. You’ll find step-by-step instructions, real-world case studies, and 50 workbooks packed with examples and solutions. Check out Microsoft Excel 2019 VBA and Macros today!

More ExcelTips (menu)

Putting Spreadsheet Names in Headers or Footers

One of the things you can add to your page header or footer is the name of your workbook file name. Here's how to make ...

Discover More

Specifying Date Formats in Headers

Don't like the default date format used by Excel when you place the date in a header or footer? You can use a macro to ...

Discover More

Turning Headers On and Off

Normally Excel displays row and column headers in a worksheet. If you prefer, you can turn these navigational aids off ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 0 + 1?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

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.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.