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

Moving a Worksheet

Need to move a worksheet from one place to another in the same workbook? Here are two easy ways to make the move.

Discover More

Adding Vertical Lines between Columns

Columns can be an integral part of your document layout. In some instances you may want Word to insert a vertical line ...

Discover More

Discovering Dependent Workbooks

When you starting linking information from one workbook to another, those workbooks become dependent on each other. ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

MORE EXCELTIPS (MENU)

Setting Up Your Printer

Need your printed output to look its best? You may need to change the settings used by your printer, then. Here's how to get ...

Discover More

Specifying a Paper Tray in a Macro

If you are using a macro to create your printed Excel output, you may need a way to specify that paper should come from a ...

Discover More

Setting Print Titles

Excel allows you to specify certain rows or columns that will be repeated on the pages of a printout. Here's how to set those ...

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?

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.


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