Range.AutoFilter (Excel)

Filters a list by using the AutoFilter.

If you omit all the arguments, this method simply toggles the display of the AutoFilter drop-down arrows in the specified range. Excel for Mac does not support this method. Similar methods on Selection and ListObject are supported. Unlike in formulas, subfields do not require brackets to include spaces.

AutoFilter (Field, Criteria1, Operator, Criteria2, VisibleDropDown, SubField)

Worksheets("Sheet1").Range("A1").AutoFilter _
 Field:=1, _
 Criteria1:="Otis", _
 VisibleDropDown:=False

Arguments

The following arguments are optional

Field - 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 (XlAutoFilterOperator) - The criteria (a string; for example, "101"). Use "=" to find blank fields, "<>" to find non-blank fields, and "><" to select (No Data) fields in data types. If this argument is omitted, the criteria is All. If Operator is xlTop10Items, Criteria1 specifies the number of items (for example, "10").

Here you can find possible values for XlAutoFilterOperator.

Operator (XlAutoFilterOperator) - An XlAutoFilterOperator constant specifying the type of filter.

Here you can find possible values for XlAutoFilterOperator.

Criteria2 (String) - The second criteria (a string). Used with Criteria1 and Operator to construct compound criteria. Also used as single criteria on date fields filtering by date, month or year. Followed by an Array detailing the filtering Array(Level, Date). Where Level is 0-2 (year,month,date) and Date is one valid Date inside the filtering period.

VisibleDropDown (Boolean) - True to display the AutoFilter drop-down arrow for the filtered field. False to hide the AutoFilter drop-down arrow for the filtered field. True by default.

SubField - The field from a data type on which to apply the criteria (for example, the "Population" field from Geography or "Volume" field from Stocks). Omitting this value targets the "(Display Value)"