Retrieve AutoFilter sets

sgremmo

Board Regular
Joined
Sep 1, 2004
Messages
55
In a macro is correct write:

Selection.AutoFilter Field:=15, Criteria1:="=S", Operator:=xlOr, _
Criteria2:="=S2"

Is possible in a macro retrive if on a worksheet are active autofilter and with kind of sets (Fields, criterias etc.)?

Thank for help.

Simone
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hi Simone

If I undertand you correctly then

Code:
Sub isAutofilterOn()
    MsgBox ActiveSheet.AutoFilterMode
End Sub

Function FilterCriteria(Rng As Range) As String
    Application.Volatile
    'By Stephen Bullen
    Dim Filter As String
    Filter = ""
    On Error GoTo Finish
    With Rng.Parent.AutoFilter
        If Intersect(Rng, .Range) Is Nothing Then GoTo Finish
        With .Filters(Rng.Column - .Range.Column + 1)
            If Not .On Then GoTo Finish
            Filter = .Criteria1
            Select Case .Operator
            Case xlAnd
                Filter = Filter & " AND " & .Criteria2
            Case xlOr
                Filter = Filter & " OR " & .Criteria2
            End Select
        End With
    End With
Finish:
    FilterCriteria = "List is being filtered for " & Filter
End Function

With the Function you need to place a formula that refrences this function and your data range that is being Filtered for Each Column.
 
Upvote 0
Yes, it work perfectly!

This evening, at home, I'll try on my worksheet...

Many thanks

Simone
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,862
Members
449,052
Latest member
Fuddy_Duddy

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