Printing Only Selected Rows from a Table

Written by Allen Wyatt (last updated December 30, 2023)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021


Michael has a table that is quite long. One column of the table contains coding characters such as the letters c, b, x, etc. He wonders if there is a way when he prints the table to only print those rows that have a specific coding character in the column. For instance, he may want to print only those rows that contain the code "c" in the coding column.

There are a couple of approaches you could use to tackle this problem. Perhaps the easiest method would be to copy the table to an Excel worksheet and then filter the data based on the characters in the coding column. You can then print the filtered worksheet and have just what you want.

Of course, there may be times when working in Excel instead of Word is not practical or desirable. For instance, you might not have Excel or you may have formatting needs that exceed what Excel can provide. In that case, you could simply sort your table in Word based on the contents of the coding column. Then, select those table rows that contain the code you want printed (they should all be contiguous since you sorted the table) and choose to print. When specifying what to print, however, print only the selection.

Another possible approach is to use your table as the data source for a mail merge. I won't go into the exact steps to use when designing the mail merge (they've been covered in other WordTips), but you can specify that the merge include only those that have the desired character in the coding column.

Finally, if you need to do this selective printing quite often, you may want to create a macro to handle the task. The easiest way to do this is for the macro to create a new document and copy the desired rows to that document.

Sub CopyTableRows()
    Dim SourceDoc As Document
    Dim r As Row
    Dim iCol As Integer
    Dim sPCode As String
    Dim sTemp As String

    iCol = 3        ' Set the coding column
    sPCode = "C"    ' Set code to select (must be uppercase)

    ScreenRefresh = False

    Set SourceDoc = ActiveDocument      ' Get active document's name
    Documents.Add       ' Create a new document

    ' Find all rows that have correct code in the coding column
    For Each r In SourceDoc.Tables(1).Rows
        sTemp = UCase(r.Cells(iCol).Range)
        sTemp = Left(sTemp, Len(sTemp) - 2)     ' Remove cell overhead
        
        If sTemp = sPCode Then
            r.Range.Copy
            Selection.PasteAndFormat wdFormatOriginalFormatting
        End If
    Next r

    ScreenRefresh = True
End Sub

In order to use the macro, you need to make sure that iCol is set to the column used as your coding column and that sPCode contains the code you want to choose. (This should be all uppercase.) When the macro is done, you'll have a document that contains only the rows you want to print, and you can then print that document.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (3511) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021.

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

Selective Undo

Ever wonder why you can't undo just a single edit you made a few minutes earlier? The short answer is that it could make ...

Discover More

Special Characters In Hyperlinks

Do you use special characters (such as the pound sign) in your worksheet names? If so, you could run into problems ...

Discover More

Determining Your Serial Number

The serial number assigned to your copy of Excel is valuable. It allows you to get support and is necessary for some ...

Discover More

The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!

More WordTips (ribbon)

Creating a Split Page

In WordPerfect terminology, a split page allows you to put information side-by-side on opposite halves of the page. If ...

Discover More

Aligning Digits in a Table

Placing information in your table is only half the battle. You also need to figure out the best ways to format that ...

Discover More

Setting Table Values to Three Decimal Places

If you import information into a document from another program, the values you import may not be exactly to your liking. ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, 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 + 5?

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 Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, 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.