Selective Headers and Footers

Written by Allen Wyatt (last updated January 4, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003


One of the long-time complaints about Excel is that it doesn't have a very robust method of creating and managing headers and footers. Consider the following scenario: You want to print your worksheet, but only have page numbers beginning on the second page.

There is no intrinsic method in Excel to handle this situation. There are some workarounds; for instance, you could put your first page on one worksheet (without headers or footers) and the subsequent pages on a different worksheet (which includes headers and footers). You could then print the two worksheets in one pass, and effectively achieve your goal.

If you have the Report Manager installed, you could use it to put together different reports based on the information in your worksheet. Using the Report Manager has been covered in other issues of ExcelTips. The Report Manager add-in was last distributed with Excel 2002, but you can still use it in Excel 2003.

Neither of these approaches work for all situations, however. For instance, you may not be able to split your printout into multiple worksheets, or you may not have much experience with the Report Manager (or you don't want to download and install it). If you prefer, you can create a macro which will print your worksheet as you desire.

The following macro, GoodPrint, will print the first page of a worksheet without headers or footers, and then all subsequent pages as normal.

Sub GoodPrint()
    Dim hlft As String
    Dim hctr As String
    Dim hrgt As String
    Dim flft As String
    Dim fctr As String
    Dim frgt As String

    'save current header
    hlft = ActiveSheet.PageSetup.LeftHeader
    hctr = ActiveSheet.PageSetup.CenterHeader
    hrgt = ActiveSheet.PageSetup.RightHeader

    'save current footer
    flft = ActiveSheet.PageSetup.LeftFooter
    fctr = ActiveSheet.PageSetup.CenterFooter
    frgt = ActiveSheet.PageSetup.RightFooter

    'remove header and footer
    With ActiveSheet.PageSetup
        .CenterHeader = ""
        .RightHeader = ""
        .LeftHeader = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftFooter = ""
    End With

    'print page one
    ActiveSheet.PrintOut 1, 1

    'restore header and footer
    With ActiveSheet.PageSetup
        .LeftHeader = hlft
        .CenterHeader = hctr
        .RightHeader = hrgt
        .LeftFooter = flft
        .CenterFooter = fctr
        .RightFooter = frgt
    End With

    'print the rest of the pages
    ActiveSheet.PrintOut 2
End Sub

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

Converting Text to Comments

One of the strong suits of macros is that they can process the information in a document quickly and reliably. For ...

Discover More

Jumping to a Relative Footnote

Footnotes can be a great addition to any document that needs detailed referencing of citations. You can navigate from one ...

Discover More

Finding Positions of Formatted Characters in a Cell

With a little bit of work, Excel allows you to format individual characters of the text you place in a cell. If you want ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development 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

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

Discover More

Creating a Footer

Adding a predefined footer to your worksheets is easy, and it helps convey valuable information when you make a printout. ...

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 6 - 0?

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.