Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looking for Excel Macro to Show Active Filter Values

Status
Not open for further replies.

alex20850

Programmer
Mar 28, 2003
83
US
I remember seeing an Excel macro in a book or online that showed the values in filters in use with Autofilter on a line about the column headings. Would love to find it again.
 
Maybe try looking in the VBA forum: Forum707

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
I found what I was looking for at:

It creates a AutoFilter_Criteria function that you can use to display the filter in use.

[]

Code:
Function AutoFilter_Criteria(Header As Range) As String
Dim strCri1 As String, strCri2 As String
    Application.Volatile
    With Header.Parent.AutoFilter
        With .Filters(Header.Column - .Range.Column + 1)
            If Not .On Then Exit Function
                strCri1 = .Criteria1
            If .Operator = xlAnd Then
                strCri2 = " AND " & .Criteria2
            ElseIf .Operator = xlOr Then
                strCri2 = " OR " & .Criteria2
            End If
        End With
    End With
    AutoFilter_Criteria = UCase(Header) & ": " & strCri1 & strCri2
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top