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
object.AutoFilter
Syntax 2
object.AutoFilter(field, criteria1, operator, criteria2)
object
Required. The Range object.
field
Required. The integer offset of the field on which to base the filter (from the left of the list-the leftmost field is field one).
criteria1
Optional. The criteria (a string; for example "101"). Use "=" to find blank fields, "<>" to find non-blank 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. Used with criteria1 and criteria2 to construct compound criteria. Can be either xlAnd or xlOr. If omitted, xlAnd is used. Specify xlTop10Items to use the Top 10 AutoFilter.
criteria2
Optional. 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 show only the entries in which field one is equal to the string "Otis".
Worksheets("Sheet1").Range("A1").AutoFilter _ field:=1, _ criteria1:="Otis"