Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to display / show auto filter criteria in Excel?

Auto Filter is a useful feature for Excel users, sometimes, we apply the Auto Filter to filter the data by multiple criterion and send the file to others. In this situation, if the other users want to know your filtered criterion, how could they do?

Display / Show auto filter criteria in worksheet with User Defined Function

Display / Show auto filter criteria in worksheet with VBA code

Display / Show auto filter criteria in worksheet with Kutools for Excel good idea3


Advanced Sort -- By Last Name (sort data based on criteria, such as sort by text length, sort by last name. sort by absolute value and so on.)

doc advanced sort last name

Excel Productivity Tools

Office Tab: Bring powerful tabs to Office (include Excel), just like Chrome, Safari, Firefox and Internet Explorer. Save you half the time, and reduce thousands of mouse clicks for you. 30-day Unlimited Free Trial

Kutools for Excel: Save 70% of your time and solve 80% Excel problems for you. 300+ advanced features designed for 1500+ work scenario, make Excel much easy and increase productivity immediately. 60-day Unlimited Free Trial


Display / Show auto filter criteria in worksheet with User Defined Function


Supposing you have the following data which has been filtered by some criterion, see screenshot:

doc-show-filter-criteria1

And now I can create a User Defined Function to display the filter criterion into the cells, please do with following steps:

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications Window.

2. Click Insert > Module, and paste the following macro in the Module Window:

Function AutoFilter_Criteria(Rng As Range) As String
'Updateby20140220
Dim str1 As String, str2 As String
Application.Volatile
With Rng.Parent.AutoFilter
    With .Filters(Rng.Column - .Range.Column + 1)
        If Not .On Then Exit Function
            str1 = .Criteria1
        If .Operator = xlAnd Then
            str2 = " AND " & .Criteria2
        ElseIf .Operator = xlOr Then
            str2 = " OR " & .Criteria2
        End If
    End With
End With
AutoFilter_Criteria = UCase(Rng) & ": " & str1 & str2
End Function

3. Then save and close this code, in a blank cell of a blank row, for example cell A1, enter this formula =AutoFilter_Criteria(A4) (A4 is the header cell of the filtered data), see screenshot:

doc-show-filter-criteria1

4. Then press Enter key, and then select cell A1, drag the fill handle over to right cells that you need to contain this formula, and all the criterion has been displayed into the cells, see screenshot:

doc-show-filter-criteria1

Note: If there are more than two criterion in a column, this User Defined Function will not give the right result.


Display / Show auto filter criteria in worksheet with VBA code

Here, I can also talk about an interesting VBA code, it can help you to display the filter criteria in a cell of the workbook.

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications Window.

2. Click Insert > Module, and paste the following macro in the Module Window:

VBA code: Display auto filter criteria in worksheet

Sub ShowAutoFilterCriteria()
'Updateby20140219
Dim xFilter As AutoFilter
Dim TargetFilter As Filter
Dim TargetField As String
Dim xOut As String
Dim OutRng As Range
If ActiveSheet.AutoFilterMode = False Then
    Application.StatusBar = False
    Exit Sub
End If
xTitleId = "KutoolsforExcel"
Set OutRng = Application.Selection
Set OutRng = Application.InputBox("Cell", xTitleId, OutRng.Address, Type:=8)
Set xFilter = ActiveSheet.AutoFilter
For i = 1 To xFilter.Filters.Count
   TargetField = xFilter.Range.Cells(1, i).Value
   Set TargetFilter = xFilter.Filters(i)
   If TargetFilter.On Then
        On Error GoTo OutNext
        xOut = xOut & TargetField & TargetFilter.Criteria1
        Select Case TargetFilter.Operator
            Case xlAnd
            xOut = xOut & " And " & TargetField & TargetFilter.Criteria2
            Case xlOr
            xOut = xOut & " Or " & TargetField & TargetFilter.Criteria2
            Case xlBottom10Items
            xOut = xOut & " (bottom 10 items)"
            Case xlBottom10Percent
            xOut = xOut & " (bottom 10%)"
            Case xlTop10Items
            xOut = xOut & " (top 10 items)"
            Case xlTop10Percent
            xOut = xOut & " (top 10%)"
        End Select
    End If
Next
OutRng.Value = xOut
OutNext:
xOut = xOut & TargetField & "= Multiple Filters"
ErrorHandler:
Resume Next
End Sub

3. Then press F5 key to run this code, a prompt box will pop out to let you select a blank cell to put the criterion, see screenshot:

doc-show-filter-criteria1

4. And then click OK, all the criterion has been shown in the selected cell as follows:

doc-show-filter-criteria1

Note:

With this VBA code, if your criterion more than two in a column, it will not be showed the detailed filter criterion but displayed as follows:

doc-show-filter-criteria1


Display / Show auto filter criteria in worksheet with Kutools for Excel

If you have Kutools for Excel installed, you can apply its Super Filter function to filter data, and at the same time you can view the filter criteria anytime.

Kutools for Excel, with more than 120 handy Excel functions, enhance your working efficiency and save your working time.

After free installing Kutools for Excel, please do as below:

1. Click Enterprise > Super Filter to display the Super Filter function. See screenshot:
doc super filter 1

2. In the Super Filter pane, click doc select button to select the data range you want to filter, and then specify the filter criteria in the pane. See screenshot:
doc super filter 2

3. Click Filter, and the selected data has been filtered by the criteria, and at the mean while, you can view the filter criteria is displyed in the Super Filter pane. See screenshot:
doc super filter 3



pay attention1If you are interested in this addi-in, download the 60-days free trial.

Excel Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 70%, and Help You To Stand Out From Crowd

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for you.

  • Designed for 1500+ work scenarios, helps you solve 80% Excel problems.
  • Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  • Being used by 110,000 elites and 300+ well-known companies.

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Hussain · 2 years ago
    Dear Sir,

    Please see here below mentioned query for your easy understanding.
    I want to see the result in column E7 when i filter data in column A3


    (Column E7) Vendor Name:

    (column A3) Vendor Name
    Abdul Aziz Fahad Al Hajri Est
    Ali-Ahmed-Al-Kanfari Gen. Co. Est.
    Amtar Al-Watan Const. & Dev. Est.
    Arab Al-Tamuz for Cont. Est.
    Arkal Est. for Cont.
    Danat Al-Rayan
    Gray Falcon
  • To post as a guest, your comment is unpublished.
    AlexM · 3 years ago
    Hi,

    The code for show auto filter criteria in the worksheet works great. As suggested, if there are more than two criteria, I output text saying 'multiple criteria'. However, I'd really like to be able to generate a list of what the multiple criteria are. Is this at all possible?

    Cheers,
    Alex
  • To post as a guest, your comment is unpublished.
    Wendy · 4 years ago
    hi there, thank you for the code, it works like a charm.

    One thing I have trouble with thouhg - when I select filter criteria the designated cell displays whichever two I had selected. If then I select two different criteria the designated cell content doesn't refresh. It seems stuck at my first filter selection.

    Is there anythig I can do?

    Thank you,
    Wendy
  • To post as a guest, your comment is unpublished.
    Wendy · 4 years ago
    This code is great and has helped me a lot.
    I ran into a problem when I tried to select new filter criteria. The cell that displays the filter criteria selected doesnt refresh when I am selecting new criteria.

    Please help, Thank you, Wendy