Multiple Line Headers and Footers

by Allen Wyatt
(last updated September 13, 2019)

7

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"

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

Turning Off Word's Second Guessing with Quote Marks

When you type quote marks in a document, Word normally changes them to Smart Quotes. They look better on a printout, but ...

Discover More

Combining Numbers and Text in a Cell

There are times when it can be beneficial to combine both numbers and text in the same cell. This can be easily done ...

Discover More

Macro for Month Name

Need to know how to generate a full month name based on a date? It's easy to do, as discussed in this tip.

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)

Moving Part of a Footer Down a Line

Setting up a single footer line for your printouts is fairly easy. If you want to move part of the footer down a line so ...

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

Putting Headers and Footers On Multiple Worksheets

You can easily create headers and footers for multiple worksheets by working with a selection set of the worksheets you ...

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 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 8 + 0?

2018-11-30 10:09:56

laura

The first one doesn't work, the second one works. the only difference is left part of equal sign. the right parts are the same. is it because the text is too long? but how come the second one works? anyone can help? thanks!

.LeftFooter ="&6" & "For Investment Professional use only, not to be shown or distributed to clients, prospective clients, or the general public." & Chr(13) & "Performance shown is net of Fund fees and expenses, except where indicated. Past performance does not guarantee future results."


.FirstPage.LeftFooter.Text = "&6" & "For Investment Professional use only, not to be shown or distributed to clients, prospective clients, or the general public." & Chr(13) & "Performance shown is net of Fund fees and expenses, except where indicated. Past performance does not guarantee future results."


2018-11-29 16:52:05

laura

The first one doesn't work, the second one works. the only difference is left part of equal sign. the right parts are the same. is it because the text is too long? but how come the second one works? anyone can help? thanks!

.LeftFooter ="&6" & "For Investment Professional use only, not to be shown or distributed to clients, prospective clients, or the general public." & Chr(13) & "Performance shown is net of Fund fees and expenses, except where indicated. Past performance does not guarantee future results."


.FirstPage.LeftFooter.Text = "&6" & "For Investment Professional use only, not to be shown or distributed to clients, prospective clients, or the general public." & Chr(13) & "Performance shown is net of Fund fees and expenses, except where indicated. Past performance does not guarantee future results."


2018-11-29 16:45:51

laura

The first one doesn't work, the second one works. the only difference is left part of equal sign. the right parts are the same. is it because the text is too long? but how come the second one works? anyone can help? thanks!

.LeftFooter ="&6" & "For Investment Professional use only, not to be shown or distributed to clients, prospective clients, or the general public." & Chr(13) & "Performance shown is net of Fund fees and expenses, except where indicated. Past performance does not guarantee future results."


.FirstPage.LeftFooter.Text = "&6" & "For Investment Professional use only, not to be shown or distributed to clients, prospective clients, or the general public." & Chr(13) & "Performance shown is net of Fund fees and expenses, except where indicated. Past performance does not guarantee future results."


2018-11-29 16:37:39

laura

I have two exact the same statements using Chr(13) in the same module for two different pages, one statement works the other doesn't work. can 't figure out why. any thoughts?


2017-09-28 13:54:16

Mark

I have the following line in my macro code:

With ActiveSheet.PageSetup
.CenterHeader = "&F" & Chr(10) & "&A"

This seems to follow the format mentioned above, but I only get the filename and nothing else. The macro doesn't error out, it just doesn't put the carriage return and tab name in. I realize this is using Chr(10), but I've also tried Chr(13) to no avail. Any thoughts?


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.


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.