Show Filtered Criteria within Excel Tables (VBA)

JayB0730

Board Regular
Joined
Oct 22, 2014
Messages
74
Office Version
  1. 365
Platform
  1. Windows
Hello,

I found several examples of displaying filtered criteria on the internet; however, they don't appear to work for worksheets that contain data within an Excel table. I've tried everything and nothing seems to help. Here is my problem:

Imagine I have an Excel table with the following columns:

CustomerID (FILTERED BASED ON COLOR YELLOW)DateCategory 1 (FILTERED)SubCategory
(FILTERED
Other

<tbody>
</tbody>

The table can be filtered up to "x" number of columns, but for the purposes of this example let's assume 3 columns can be filtered (see above). These filters are not necessarily active at the same time.

The Function/Formula displaying the results of each filter would be entered into a different cell(s) somewhere on the sheet.

Any help is greatly appreciated!

TIA
Jay
 
Last edited:

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hello,

Maybe my previous post was unclear so allow me to post the code that I did find; however, I need to convert the column codes to understand table headers instead. I think that the existing code does not work because it is not seeing the column filters inside the tables. Thoughts? Thanks!

Code:
Function AutoFilter_Criteria(rng As Range) As String'This will allow you to see Auto Filter Criteria
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
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,625
Members
449,093
Latest member
catterz66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top