FilterEdit Method

Creates, edits, or copies a filter.

Syntax

expression**.FilterEdit(Name, TaskFilter, Create, OverwriteExisting, Parenthesis, NewName, FieldName, NewFieldName, Test, Value, Operation, ShowInMenu, ShowSummaryTasks)**

*expression   *     Optional. An expression that returns an Application object.

Name    Required String. The name of a filter to edit, create, or copy.

TaskFilter    Required Boolean. True if the filter specified with Name contains task information. False if the filter contains resource information.

Create    Optional Boolean. True if a new filter is created. The new filter is a copy of the filter specified with Name and is given the name specified with NewName. If NewName is Empty , the new filter is given the name specified with Name. The default value is False.

OverwriteExisting    Optional Boolean. True if the existing filter is overwritten with a new filter. The default value is False.

Parenthesis    Optional Boolean. True if the criterion established by FieldName, Test, and Value is evaluated as a parenthetical AND or OR clause (the value specified with Operation) in relation to other criteria, in the manner of (a AND b) OR c.

NewName    Optional String. A new name for the filter specified with Name (Create is False) or a name for the new filter (Create is True). If NewName is Empty and Create is False, the filter specified with Name retains its current name. The default value is Empty.

FieldName    Optional String. The name of a field to change.

NewFieldName    Optional String. A new name for the field specified with FieldName.

Test    Required String. The type of comparison made between FieldName and Value that acts as selection criteria for the filter. Can be one of the following comparison strings:

Comparison String Description
"equals" The value of FieldName equals Value.
"does not equal" The value of FieldName does not equal Value.
"is greater than" The value of FieldName is greater than Value.
"is greater than or equal to" The value of FieldName is greater than or equal to Value.
"is less than" The value of FieldName is less than Value.
"is less than or equal to" The value of FieldName is less than or equal to Value.
"is within" The value of FieldName is within Value.
"is not within" The value of FieldName is not within Value.
"contains" FieldName contains Value.
"does not contain" FieldName does not contain Value.
"contains exactly" FieldName exactly contains Value.

Value    Optional String. The value to compare with the value of the field specified with FieldName.

Operation    Optional String. How the criterion established with FieldName, Test, and Value relates to other criteria in the filter. The Operation argument can be set to "And" or "Or".

ShowInMenu    Optional Boolean. True if the filter is displayed in the Filters menu. (To display the Filters menu, click Filtered for on the Project menu.) The default value is False.

ShowSummaryTasks    Optional Boolean. True if the summary tasks of the filtered tasks are displayed. The default value is False.

Example

The following example creates a filter (if one doesn't exist) for tasks with the highest priority and then applies the filter.

Sub CreateAndApplyHighestPriorityFilter()

    Dim TaskFilter As Variant  ' Index for For Each loop
    Dim Found As Boolean    ' Whether or not the filter exists.

    Found = False   ' Assume the filter doesn't exist.

    ' Look for filter.
    For Each TaskFilter In ActiveProject.TaskFilterList
        If TaskFilter = "Highest Priority" Then
            Found = True
            Exit For
        End If
    Next TaskFilter

    ' If filter doesn't exist, create it.
    If Not Found Then FilterEdit Name:="Highest Priority", _
        Create:=True, TaskFilter:=True, FieldName:="Priority", _
        Test:="equals", Value:="Highest"

    FilterApply "Highest Priority"
    
End Sub

Applies to | Application Object

See Also | CheckField Method | FilterApply Method | Filters Method | Find Method | FindNext Method | FindPrevious Method | ResourceFilterList Property | TaskFilterList Property