April 2006
Beginner
1114 pages
98h 16m
English
autofilter.Filters(index)
The Filters collection returns a Filter object with read-only properties that list the state and criteria for each filtered column on the worksheet. You can’t change or apply filters through the Filters collection; you can only read the settings and then only if the filter is on as shown here:
Sub ShowFilters( )
Dim ws As Worksheet, flt As Filter, i As Integer
Set ws = ActiveSheet
' If there are filters
If ws.AutoFilterMode Then
' Get each Filter object
For i = 1 To ws.AutoFilter.Filters.Count
Set flt = ws.AutoFilter.Filters(i)
' And if the filter is on, show its criterion.
If flt.On Then
Debug.Print "Column " & i & ": " & flt.Criteria1
End If
Next
End If
End SubUse the Range object’s AutoFilter method to set Filter properties and apply filters.
Read now
Unlock full access