REPLACE

Replaces part of a text string with a different text string.

Syntax

REPLACE(old_text,start_num,num_chars,new_text)

Old_text   is text in which you want to replace some characters.

Start_num   is the position of the character in old_text that you want to replace with new_text.

Num_chars   is the number of characters in old_text that you want to replace with new_text.

New_text   is the text that will replace characters in old_text.

Examples

The following formula replaces five characters with new_text, starting with the sixth character in old_text:

REPLACE("abcdefghijk", 6, 5, "*") equals "abcde*k"

The sixth through tenth characters are all replaced by "*".

The following formula replaces the last two digits of 1990 with 91:

REPLACE("1990", 3, 2, "91") equals "1991"

If cell A2 contains "123456", then:

REPLACE(A2, 1, 3, "@") equals "@456"

If the RIGHT function returns "ABCDEF", then:

REPLACE(RIGHT(A3, 6), 1, 6, "*") equals "*"