Multiple Line Headers and Footers

by Allen Wyatt
(last updated November 15, 2014)

2

If you use a macro code to set your header or footer, you can designate more than one line for them. Thus, you could have a two or three line header or footer, if desired. You do this by simply including the code Chr(13) into the string you use to set the header or footer. When used with the command codes discussed in other issues of ExcelTips, this is very powerful, indeed.

For instance, let's say you wanted a centered header that included your company name on the first line with today's date on the second. You would use the following code:

ActiveSheet.PageSetup.CenterHeader = "&C&BAmalgamated Widgets, Inc.&B"
& Chr(13) & "&D"

Note the use of the &B command code to make the company name bold. The second use of the command code is to turn the bold attribute off, so that the date does not end up being bold. Also, note the use of the &C command code. Remember that the use of positioning command codes such as these overrides placement. Thus, the following code (which would normally place the information at the left side of the header) has the exact same results as the previous code:

ActiveSheet.PageSetup.LeftHeader = "&C&BAmalgamated Widgets, Inc.&B"
& Chr(13) & "&D"

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (1992) 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

Can't Empty the Clipboard

The Clipboard is essential to move or copy information from one place in Excel to another. If you get an error when you try ...

Discover More

Inserting Summary Information

Want to insert into your document those snippets of information that you know Word maintains about your document? It's easy ...

Discover More

Finding Information in the Registry

The Registry is the central depository of configuration information used by Windows and by programs running on your system. ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

MORE EXCELTIPS (MENU)

Leading Zeros in Page Numbers

Page numbers in Excel printouts are typically simple counters, without much chance for embellishment. If you want to add ...

Discover More

Copying Headers and Footers

Need to copy headers and footers from one worksheet to another? How about from one workbook to another? Here are some ...

Discover More

Positioning Headers and Footers

If your workbook is destined for the printed page, you need to be concerned with the layout of that page. Excel allows you to ...

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 for this tip:

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. 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 three minus 0?

2015-03-27 09:58:05

Chuck Siegmann

This is great, but how do you create multiple heared lines when you don't use macro codes to set the headers and footers. Limitations like this is why i spend so much time creating tables in Word.


2014-11-18 10:12:23

Don

It's frustrating when you have ads that cover up text in your article.


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.

Links and Sharing
Share