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
 

Some videos you may like

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

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
 

Watch MrExcel Video

Forum statistics

Threads
1,109,359
Messages
5,528,225
Members
409,809
Latest member
VICKRAM

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top