Compartir a través de


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)

Syntax

'Declaration
Function AutoFilter ( _
    Field As Object, _
    Criteria1 As Object, _
    Operator As XlAutoFilterOperator, _
    Criteria2 As Object, _
    VisibleDropDown As Object _
) As Object
'Usage
Dim instance As Range
Dim Field As Object
Dim Criteria1 As Object
Dim Operator As XlAutoFilterOperator
Dim Criteria2 As Object
Dim VisibleDropDown As Object
Dim returnValue As Object

returnValue = instance.AutoFilter(Field, _
    Criteria1, Operator, Criteria2, VisibleDropDown)
Object AutoFilter(
    Object Field,
    Object Criteria1,
    XlAutoFilterOperator Operator,
    Object Criteria2,
    Object VisibleDropDown
)

Parameters

  • Field
    Type: System.Object

    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
    Type: System.Object

    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").

  • Criteria2
    Type: System.Object

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

  • VisibleDropDown
    Type: System.Object

    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.

Return Value

Type: System.Object

Remarks

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.

See Also

Reference

Range Interface

Range Members

Microsoft.Office.Interop.Excel Namespace