Excel REPLACE Function

REPLACE swaps characters in a text value by starting position and length.

Use it to rewrite fixed-width codes, mask part of an ID, insert a prefix, or update text when the character positions are predictable.

1
Choose source text This is the string to edit
2
Choose start and length Positions decide what gets removed
3
Insert new text The replacement is returned in place

REPLACE syntax & arguments

Syntax

=REPLACE(old_text, start_num, num_chars, new_text)
Required Optional
  1. 1

    old_text

    Required

    The original text value, cell reference, or formula result to edit.

  2. 2

    start_num

    Required

    The character position where replacement should begin.

  3. 3

    num_chars

    Required

    How many characters to remove from old_text starting at start_num.

  4. 4

    new_text

    Required

    The text to insert in place of the removed characters.

Example

=REPLACE(A2, 4, 2, "US")

Replace two characters in A2 starting at character 4 with US.

REPLACE caveats

  • Positions start at 1

    start_num of 1 begins at the first character. A start_num less than 1 returns a #VALUE! error.

  • num_chars controls deletion

    num_chars is how many old characters are removed before new_text is inserted.

  • num_chars can be zero

    Use 0 for num_chars when you want to insert new_text without removing any existing characters. Excel inserts it before the character at start_num, so =REPLACE("abcd", 2, 0, "X") returns aXbcd.

  • REPLACE does not search

    Use FIND to calculate a position, or use SUBSTITUTE when matching text should be replaced wherever it appears.

Need delimiter-based edits? Use FIND to calculate start_num when the replacement should begin at a delimiter or marker that can appear in different positions.

Intro REPLACE practice problem

Solve the intro problem directly here, or open it on its own page.

Open full problem

Advanced REPLACE practice problems

Use REPLACE alongside other Excel functions in realistic, less-prescriptive challenges.