Header and Footer Data Codes

by Allen Wyatt
(last updated August 29, 2016)

4

Excel includes a number of codes which you can include in your header and footer. These codes are designed to make including predefined information a bit easier. Some of the codes are available on the Header or Footer dialog boxes (when you click on Custom Header or Custom Footer in the Header/Footer tab of the Page Setup dialog box) by clicking on a button. Others you must enter directly.

Command codes are indicated in Excel headers and footers by typing an ampersand character (&) followed by the command. The following are the data codes you can use:

Code Meaning
&D Current date
&T Current time
&F Workbook name
&A Worksheet name (from the worksheet tab)
&P Current page number
&P+x Current page number plus x
&P-x Current page number minus x
&N Total pages in the workbook
&& Ampersand character

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2056) applies to Microsoft Excel 97, 2000, 2002, and 2003.

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

Wrong Values Merged from Excel

When you use an Excel workbook as a data source for your merged document, you may be surprised if what is merged doesn't ...

Discover More

Saving All Open Documents

Got a lot of open documents you are working with? You can save them all at one time by adding a handy tool to your Quick ...

Discover More

Decimal Tab Alignment

If you are familiar with decimal tabs in Word, you may wonder if you can set the same sort of alignment in Excel. The short ...

Discover More

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!

More ExcelTips (menu)

Header and Footer Background Color

Want to add some color to the printing of your page headers and footers? Your options are limited, as disclosed in this tip.

Discover More

Putting a Different Date in a Header

Today's date is easy to add to a header, but what if you want to add a date that is adjusted in some manner? Adding ...

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

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}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 8Mpixels. 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 eight more than 8?

2017-02-27 16:03:54

Sarah

Is it possible to insert the Sheet number (not the page number) into the Header? So that the first sheet is Table 1, the second is Table 2, etc?


2015-09-03 00:38:07

Jordan

I need to a different date than the current one. Specifically, tomorrow's date, or +1. Is this possible in the header?


2013-03-03 00:11:35

Peter J Moran

Hi Jim,
Check this tip:
Creating Default Formatting for Workbooks and Worksheets
set up your footers as required and follow the tip. All your workbooks will now have a standard footer.


2013-03-02 08:59:56

Jim Carroll

To me, the filename and path are at least as important as date, time, worksheet name, etc. At my age, it's hard to remember what folder contains last year's revenue budget numbers and the like. Is it possible to include filename and path in the header or footer as it is in Word?


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.