Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Repeating Rows on a Printout Except On the Last Page.

Repeating Rows on a Printout Except On the Last Page

by Allen Wyatt
(last updated April 25, 2016)

4

Nancy knows how to format a worksheet so that rows are repeated at the top of each page of a printout. What she wants to do, however, is to have the rows repeated at the top of each printed page except the last one.

There is no direct way to do this, but you can simulate such a printing by using a macro to do the task. All you need to do is have the macro print all except your last page, then change the page setup so that rows are not repeated, and finally print the final page of the printout. The following macro provides an example of this approach.

Sub PrintWorksheet()
    Dim lPages As Long
    Dim sTemp As String

    lPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
    With ActiveSheet.PageSetup
        ActiveSheet.PrintOut From:=1, To:=lPages - 1
        sTemp = .PrintTitleRows
        .PrintTitleRows = ""
        ActiveSheet.PrintOut From:=lPages, To:=lPages
        .PrintTitleRows = sTemp
    End With
End Sub

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3389) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Repeating Rows on a Printout Except On the Last Page.

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

Protecting Many Worksheets

Need to protect a lot of worksheets? Rather than protect the sheets individually, you'll appreciate the macros discussed in ...

Discover More

Two Printed Copies to Different Paper Trays

Many modern printers include multiple paper trays that can be used for different types or colors of paper. Word allows you to ...

Discover More

Changing the MAC Address for a Network Adapter

MAC addresses are used to uniquely identify devices on your network, such as a network adapter. Here's how you can modify the ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

MORE EXCELTIPS (MENU)

Specifying Print Quantity in a Cell

When you print a worksheet, you can specify in the Print dialog box how many copies you want printed. If you want the print ...

Discover More

Printing Rows Conditionally

Need to only print out certain rows from your data? It's easy to do if you apply the filtering or sorting techniques ...

Discover More

Massive Printouts

Have you ever wanted to do a simple printout, only to find that Excel spit out dozens of pages, and most of them were blank? ...

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

2016-11-07 09:32:19

Luke Skaff

The problem with this approach is when you remove the repeating rows to print the last page it shifts all the data up as the repeating row is not longer taking up space. This causes the last past to be missing some of the rows from the spreadsheet.

What needs to be done is the code has to grab where the divider page break is for the last page printing, print the all pages but the last page, remove the repeating row, change the page break on the last page to the original position that it was before removing the repeating header row, then print the last page


2016-05-20 15:39:22

Kim

Hi,
This is not working for me. On the last page of the document, the title row is not present (Yay!), but the first couple of rows are missing.
Thanks


2015-03-17 03:03:01

Joey Liang

How about export it in PDF? I've tried for printout, it works well. But I need the same for exporting to PDF in excel 2013.


2011-11-02 15:51:01

Jim Miller

Thanks for posting this. It's exactly what I was looking for and great for a VB newbie.


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.

Links and Sharing