Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, and 2016. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Showing Filter Criteria on a Printout.
by Allen Wyatt
(last updated February 27, 2016)
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:
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 place 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.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11649) applies to Microsoft Excel 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Excel here: Showing Filter Criteria on a Printout.
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!
Some types of data may have certain fields that contain partially identical information. In such cases you may want to delete ...Discover More
Accessing filtering criteria for use in a formula can be a real need for some worksheet designs. Getting to that information ...Discover More
Using the fill handle is a great way to quickly fill a range of cells with values. Sometimes, however, the way to fill cells ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.