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: Specifying Date Formats in Headers.

Specifying Date Formats in Headers

Written by Allen Wyatt (last updated October 30, 2021)
This tip applies to Excel 97, 2000, 2002, and 2003


Normally, the dates used by Excel in headers and footers (with the [DATE] code) are based on the regional settings controlled by Windows. Thus, if your local settings show the date in a specific format in Windows itself, that is the same format that Excel will use in headers and footers.

This can be a drawback if you are required to maintain a certain type of system date format for compatibility with other systems in your office, but you need to use a different date format in the header or footer of a specific worksheet. The only way around this problem is to either change the regional settings within Windows, or revert to using a macro to set the appropriate area of your header or footer.

For instance, let's say you wanted to set the right header equal to the current date in the format m/d/yy. To do that, you can use a very simple macro, such as the following:

Sub HeaderDate()
    ActiveSheet.PageSetup.RightHeader = Format(Date, "m/d/yy")
End Sub

To use this, simply run it and it adds the date, in the specified format, into the right section of the header. If you want the information added to a different place in the footer or header, you simply replace the RightHeader portion of the macro with one of the following: LeftFooter, CenterFooter, RightFooter, LeftHeader, or CenterHeader.

To change the format in which the date is added, simply change the format used in the Format function. There are all sorts of patterns you can use for the date; check the online Help system for information about the Format function in VBA.

You should note that dates added to headers or footers in this manner are not dynamic, as is the result of the [DATE] code. When you use the macro to insert the date, it is inserted as a text string. If you later want to change the date to something else (like the then-current date), you will need to rerun 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 (2188) 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: Specifying Date Formats in Headers.

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

Jumping to the Top of a Page

Do you want to easily jump to the top of a page in your document? You can use the Go To command to make the shift, or you ...

Discover More

Printing a File List

It is often helpful to have a list of all the documents in a given directory or folder. Word doesn't have a built-in way ...

Discover More

Importing a Text File and Inserting after a Bookmark

Word macros are a great way to automate some of the ways in which you create documents. If you have a need to insert the ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (menu)

Inserting the Saved Date In a Header or Footer

When preparing a worksheet for printing, you may want to include in the header or footer the last date the workbook was ...

Discover More

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

Dynamic Headers and Footers

Do you want to change the headers and footers that appear on different pages of your printout? Here's how you can get ...

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 two less than 9?

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.