AdvancedFilter Method

Applies To

Range Object.

Description

Filters or copies from a list based on a criteria range. If the initial selection is a single cell, its current region is used.

Syntax

object.AdvancedFilter(action, criteriaRange, copyToRange, unique)

object

Required. The Range object.

action

Required. Specifies the operation (either xlFilterInPlace or xlFilterCopy).

criteriaRange

Optional. The criteria range. If omitted, there are no criteria.

copyToRange

Required if action is xlFilterCopy, ignored otherwise. The destination range for the copied rows.

unique

Optional. True means unique records only, False means all records that meet the criteria. If omitted, assumed False.

See Also

AutoFilter Method, FilterMode Property, ShowAllData Method.

Example

This example filters a database (named "Database") based on a criteria range named "Criteria."


Range("Database").AdvancedFilter _
    action:=xlFilterInPlace, _
    criteriaRange:=Range("Criteria")