Skip to content
Excel

REPLACE function in Excel

Replaces characters within text

=REPLACE(old_text, start_num, num_chars, new_text)

REPLACE syntax and parameters

Four arguments, four required.

  • old_textstringRequired

    Text in which you want to replace some characters.

  • start_numnumberRequired

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

  • num_charsnumberRequired

    The number of characters in old_text that you want REPLACE to replace with new_text.

  • new_textstringRequired

    The text that will replace characters in old_text.

REPLACE examples

Formulas you'll actually reuse.

  1. Mask the first four characters of an account number:

    =REPLACE(A2, 1, 4, "XXXX")

    Result"XXXX5678"

  2. Swap the domain after the @ in an email address:

    =REPLACE(A2, FIND("@", A2) + 1, LEN(A2), "newdomain.com")

    Result"maria.lopez@newdomain.com"

REPLACE in Google Sheets

Same name — your formula ports as-is.

Try REPLACE in the playground

Edit the example — nothing to install.

Preloaded with the REPLACE formula from Example 1 — change anything and watch it respond.

Loading the editor…