SUBSTITUTE (replace text in a text string)

<< Click to Display Table of Contents >>

SUBSTITUTE (replace text in a text string)

Syntax:

SUBSTITUTE(Text, OldText, NewText [, n])

Description:

This replaces the OldText in a text string with the NewText.

Text is the original text string.

OldText is the text to be replaced. Note: This function is case-sensitive, thus it distinguishes between uppercase and lowercase letters.

NewText is the replacement text.

The optional argument n specifies which occurrence of OldText should be replaced. If n is omitted, all occurrences will be replaced.

Example:

SUBSTITUTE("aabbaabb", "aa", "xx") returns xxbbxxbb

SUBSTITUTE("aabbaabb", "aa", "xx", 2) returns aabbxxbb

SUBSTITUTE("aabbaabb", "AA", "xx") returns aabbaabb

See also:

FIND, SEARCH, REPLACE, REPT