This documentation is archived and is not being maintained.

Range.AutoFilter Method 

Filters a list using the AutoFilter.

Namespace: Microsoft.Office.Interop.Excel
Assembly: Microsoft.Office.Interop.Excel (in microsoft.office.interop.excel.dll)

'Usage
Dim Field As Object
Dim Criteria1 As Object
Dim Operator As XlAutoFilterOperator
Dim Criteria2 As Object
Dim VisibleDropDown As Object
Dim returnValue As Object
Dim range1 As Range
returnValue = range1.AutoFilter(Field, Criteria1, Operator, Criteria2, VisibleDropDown)

object AutoFilter(
	[In, Optional] object Field, 
	[In, Optional] object Criteria1, 
	[In, Optional] XlAutoFilterOperator Operator, 
	[In, Optional] object Criteria2, 
	[In, Optional] object VisibleDropDown
);
public System.Object AutoFilter(
	/*in*/System.Object Field, 
	/*in*/System.Object Criteria1, 
	/*in*/XlAutoFilterOperator Operator, 
	/*in*/System.Object Criteria2, 
	/*in*/System.Object VisibleDropDown
);
function AutoFilter(
	 Field : Object, 
	 Criteria1 : Object, 
	 Operator : XlAutoFilterOperator, 
	 Criteria2 : Object, 
	 VisibleDropDown : Object
) : Object;

Parameters

Field

Optional Object. 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 Object. 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 XlAutoFilterOperator. Can be one of the following XlAutoFilterOperator constants:

  • xlAnddefault

  • xlBottom10Items

  • xlBottom10Percent

  • xlOr

  • xlTop10Items

  • xlTop10Percent

Use xlAnd and xlOr with Criteria1 and Criteria2 to construct compound criteria.

Criteria2

Optional Object. The second criteria (a string). Used with Criteria1 and Operator to construct compound criteria.

VisibleDropDown

Optional Object. 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.

Apply the AutoFilter property to a Worksheet object to return an AutoFilter object.

If you omit all the arguments, this method simply toggles the display of the AutoFilter drop-down arrows in the specified range.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows XP Home Edition, Windows XP Professional, Windows Server 2003, and Windows 2000

Target Platforms

Show: