SUBSTITUTE (replace text in a text string)

Navigation:  Formulas and functions > Functions from A to Z >

SUBSTITUTE (replace text in a text string)

Previous pageReturn to chapter overviewNext page

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 determines how many occurrences of the 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