VBA Help with Excel Tables & Displaying Filtered Content

JayB0730

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

Looking to see who could modify this code so that it works with 1) Excel Tables & 2) More than 2 criteria. Ultimately, I want to display to the user what the filtered content is showing.

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
 
Last edited:

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,214,825
Messages
6,121,787
Members
449,049
Latest member
greyangel23

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