Written by Allen Wyatt (last updated August 6, 2022)
This tip applies to Excel 97, 2000, 2002, and 2003
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:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (1992) applies to Microsoft Excel 97, 2000, 2002, and 2003.
Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!
Place an ampersand into the text of a page header or footer, and you might be surprised to see it missing in your ...
Discover MoreWhen printing a worksheet, you may want to have the footer different on the first page of your document than it is on ...
Discover MoreEach new Excel worksheet contains a page header, by default. Follow this tip to get rid of headers you don't need.
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments