AutoFilter Method
Applies To
Range object.
Description
Syntax 1: Displays or hides the AutoFilter drop-down arrows.
Syntax 2: Filters a list using the AutoFilter.
Syntax 1
expression.AutoFilter
Syntax 2
expression.AutoFilter(Field, Criteria1, Operator, Criteria2)
expression Required. An expression that returns a Range object.
Field Optional Variant. The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field one).
Criteria1 Optional Variant. The criteria (a string; for example, "101"). Use "=" to find blank fields, or use "<>" to find nonblank fields. If this argument is omitted, the criteria is All. If Operator is xlTop10Items, Criteria1 specifies the number of items (for example, "10").
Operator Optional Variant. Can be one of the following XlAutoFilterOperator constants: xlAnd, xlBottom10Items, xlBottom10Percent, xlOr, xlTop10Items, or xlTop10Percent. Use xlAnd and xlOr with Criteria1 and Criteria2 to construct compound criteria.
Criteria2 Optional Variant. The second criteria (a string). Used with Criteria1 and Operator to construct compound criteria.
See Also
AdvancedFilter method, AutoFilterMode property, FilterMode property, ShowAllData method.
Example
This example filters a list starting in cell A1 on Sheet1 to display only the entries in which field one is equal to the string "Otis".
Worksheets("Sheet1").Range("A1").AutoFilter _
field:=1, _
criteria1:="Otis"