跳到主要内容

SetAutoFilter

Adds an AutoFilter to the current range.

Syntax

expression.SetAutoFilter(Field, Criteria1, Operator, Criteria2, VisibleDropDown);

expression - A variable that represents a ApiRange class.

Parameters

NameRequired/OptionalData typeDefaultDescription
FieldOptionalnumberThe 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).
Criteria1Optionalstring | string[] | ApiColor | XlDynamicFilterCriteriaThe 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").
OperatorOptionalXlAutoFilterOperatorAn XlAutoFilterOperator constant specifying the type of filter.
Criteria2OptionalstringThe second criteria (a string). Used with Criteria1 and Operator to construct compound criteria.
VisibleDropDownOptionalbooleanTrue 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.

Returns

This method doesn't return any data.