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.
Mask the first four characters of an account number:
=REPLACE(A2, 1, 4, "XXXX")Result
"XXXX5678"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…
Related functions
More ways Excel gets this done.
- ARRAYTOTEXTReturns an array of text values from any specified rangeTextNo Google Sheets equivalent
- CHARReturns the character specified by the code numberTextGoogle Sheets
- CLEANRemoves all nonprintable characters from textTextGoogle Sheets
- CODEReturns a numeric code for the first character in a text stringTextGoogle Sheets
- CONCATCombines the text from multiple ranges and/or strings, but it doesn't provide the delimiter or IgnoreEmpty arguments.TextGoogle Sheets
- CONCATENATEJoins several text items into one text itemTextGoogle Sheets