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: Showing Filter Criteria on a Printout.

Showing Filter Criteria on a Printout

Written by Allen Wyatt (last updated June 25, 2018)
This tip applies to Excel 97, 2000, 2002, and 2003


Microsoft Excel includes some great tools that help you filter large data tables to include only the information you want displayed. In effect, the filters allow you to "slice and dice" your data until you get just what you want.

When printing out filtered data, you might want to know what slicing and dicing was done to the original data. There are several ways you can go about displaying your filtering criteria. One simple way is to use the advanced filtering capabilities of Excel, which require that you set up a small criteria table for your data. If the criteria table is made part of what you print, then you can see your filtering criteria quite easily.

If you use AutoFilter, then you need to use a different approach. One such approach is detailed at John Walkenbach's site:

http://j-walk.com/ss/excel/usertips/tip044.htm

This solution uses a user-defined function to return any filtering criteria in use in the current column. The function can be used in a cell, in that column, to display the criteria. If you are using advanced filtering, then the macro approach is a bit more complex. The following macros (there are two of them in the listing) examine what advanced criteria are in play, and then places the criteria in the left portion of the header.

Sub AddFilterCriteria()
    Dim strCriteria As String

    strCriteria = FilterCriteria()
    If strCriteria = "" Then
        strCriteria = "No Filtering Criteria"
    Else
        strCriteria = "Filter Criteria:" & Chr(10) & strCriteria
    End If

'   add Criteria string to Header/Footer
    With ActiveSheet.PageSetup
        .LeftHeader = strCriteria
    End With
End Sub

Function FilterCriteria() As String
    Dim rngCriteria As Range, col As Range, cel As Range
    Dim strCriteria As String, r As Integer, c As Integer
    Const strCriteriaRange As String = "Criteria"

    FilterCriteria = ""

    On Error Resume Next
    'Set Criteria-Range reference
    Set rngCriteria = Range(strCriteriaRange)
    If Err <> 0 Then Exit Function
    On Error GoTo 0

'   Create Criteria String
    c = 0
    For Each col In rngCriteria.Columns
        c = c + 1     ' CriteriaRange Columns
        r = 1         ' CriteriaRange Rows
        For Each cel In col.Cells
            If r = 1 Then
                strCriteria = strCriteria & "Criteria" _
                  & c & " (" & cel.Value & ") = "
            Else
                strCriteria = strCriteria & "'" & cel.Value & "'"
                If IsEmpty(cel.Offset(1, 0)) Then
                    'Add New row Char if not Last Criteria Column
                    If c < rngCriteria.Columns.Count Then
                        strCriteria = strCriteria & Chr(10)
                    End If
                    Exit For
                End If
                strCriteria = strCriteria & "  "
            End If
            r = r + 1
        Next cel    ' next criteria row
    Next col        ' next criteria column

    FilterCriteria = strCriteria
End Function

To use the macro, just run the AddFilterCriteria macro, after you have your advanced filtering set up. The macro reads the criteria table and puts together the criteria into a string that is placed in the left header.

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 (3248) 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: Showing Filter Criteria on a Printout.

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

Inserting Endnotes

Endnotes appear at either the end of a section or the end of an entire document. It is just as easy to insert an endnote ...

Discover More

Find and Replace in Text Boxes

Find and Replace can work great, but not necessarily for text within text boxes. This tip discusses all the ins and outs ...

Discover More

Displaying the First Worksheet in a Macro

When creating macros, you often have to know how to display individual worksheets. VBA provides several ways you can ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (menu)

Working With Multiple Printers

If you have multiple printers accessible to your computer, you may need a way to quickly print your worksheet on a ...

Discover More

Printing Workbook Properties

Want to create a printed record of the properties associated with a workbook? There is no easy way to do it in Excel. ...

Discover More

Automatically Printing a Range

If you want to automatically print a particular area of your worksheet at a specific time of day, you'll love this tip. ...

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 two more than 9?

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.