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

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Ivan F Moala

MrExcel MVP
Joined
Feb 10, 2002
Messages
4,209
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.
 

sgremmo

Board Regular
Joined
Sep 1, 2004
Messages
55
Yes, it work perfectly!

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

Many thanks

Simone
 

Forum statistics

Threads
1,141,137
Messages
5,704,490
Members
421,353
Latest member
jekoxien15

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
Top