NamedRange.AdvancedFilter Method (2007 System)

Filters or copies data from a list based on a criteria range.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Syntax

'Declaration
Public Function AdvancedFilter ( _
    Action As XlFilterAction, _
    CriteriaRange As Object, _
    CopyToRange As Object, _
    Unique As Object _
) As Object
'Usage
Dim instance As NamedRange 
Dim Action As XlFilterAction 
Dim CriteriaRange As Object 
Dim CopyToRange As Object 
Dim Unique As Object 
Dim returnValue As Object 

returnValue = instance.AdvancedFilter(Action, _
    CriteriaRange, CopyToRange, Unique)
public Object AdvancedFilter(
    XlFilterAction Action,
    Object CriteriaRange,
    Object CopyToRange,
    Object Unique
)
public:
Object^ AdvancedFilter(
    XlFilterAction Action, 
    Object^ CriteriaRange, 
    Object^ CopyToRange, 
    Object^ Unique
)
public function AdvancedFilter(
    Action : XlFilterAction, 
    CriteriaRange : Object, 
    CopyToRange : Object, 
    Unique : Object
) : Object

Parameters

  • CriteriaRange
    Type: System.Object

    The criteria range. If this argument is omitted, there are no criteria.

  • CopyToRange
    Type: System.Object

    The destination range for the copied rows if Action is xlFilterCopy. Otherwise, this argument is ignored.

  • Unique
    Type: System.Object

    true to filter unique records only; false to filter all records that meet the criteria. The default value is false.

Return Value

Type: System.Object

Remarks

If the initial selection is a single cell, that cell's current region is used.

Optional Parameters

For information on optional parameters, see The Variable missing and Optional Parameters in Office Solutions.

Examples

The following code example sets integer values in the range of cells from A1 through A5 and then uses the AdvancedFilter method to filter and copy the values to the range of cells starting at B1.

This example is for a document-level customization.

Private Sub ActivateAdvancedFilter()
    Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
        = Me.Controls.AddNamedRange(Me.Range("A1", "A5"), _
        "namedRange1")

    Me.Range("A1").Value2 = 10
    Me.Range("A2").Value2 = 10
    Me.Range("A3").Value2 = 20
    Me.Range("A4").Value2 = 10
    Me.Range("A5").Value2 = 30

    namedRange1.AdvancedFilter(Excel.XlFilterAction.xlFilterCopy, , _
        Me.Range("B1"), True)
End Sub
private void ActivateAdvancedFilter()
{
    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1", "A5"],
        "namedRange1");

    this.Range["A1", missing].Value2 = 10;
    this.Range["A2", missing].Value2 = 10;
    this.Range["A3", missing].Value2 = 20;
    this.Range["A4", missing].Value2 = 10;
    this.Range["A5", missing].Value2 = 30;

    namedRange1.AdvancedFilter(Excel.XlFilterAction.xlFilterCopy,
        missing, this.Range["B1", missing], true);
}

.NET Framework Security

See Also

Reference

NamedRange Class

NamedRange Members

Microsoft.Office.Tools.Excel Namespace