Replace Method

Searches for an unfiltered value and replaces it with the specified value. The Replace method returns True if replacements were made.

Syntax

expression**.Replace(Field, Test, Value, Replacement, ReplaceAll, Next, MatchCase)**

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

Field    Required String. The name of the field to search.

Test    Required String. The type of comparison made between Field and Value. Can be one of the following comparison strings:

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

Value    Required String. The value to compare with the value of the field specified with Field.

Replacement    Required String. The text used to replace Value. Use "" (an empty string) to clear Field where it meets the test specified by Test and Value.

ReplaceAll    Optional Boolean. True if all occurrences of Value are replaced. False if only the first occurrence is replaced. The default value is False.

Next    Optional Boolean. True if Microsoft Office Project 2003 searches down for the next occurrence of matching search criteria. False if the program searches up for the next occurrence. The default value is True.

MatchCase    Optional Boolean. True if the search is case-sensitive. The default value is False.

Remarks

Using the Replace method without specifying any arguments displays the Replace dialog box.

Example

The following example lowers the priority of all tasks from highest to high.

Sub LowerPriority()
    Application.Replace Field:="Priority", Test:="equals", Value:="Highest", Replacement:="High", _
        ReplaceAll:=True
End Sub

Applies to | Application Object

See Also | Find Method | FindNext Method | FindPrevious Method