AutoFilter Property

Microsoft Excel Visual Basic

AutoFilter Property

       

Returns an AutoFilter object if filtering is on. Returns Nothing if filtering is off. Read-only.

Remarks

To create an AutoFilter object for a worksheet, you must turn autofiltering on for a range on the worksheet either manually or using the AutoFilter method of the Range object.

Example

The following example sets a variable to the value of the Criteria1 property of the filter for the first column in the filtered range on the Crew worksheet.

With Worksheets("Crew")
    If .AutoFilterMode Then
        With .AutoFilter.Filters(1)
            If .On Then c1 = .Criteria1
        End With
    End If
End With