Change a prefix
| A | |
|---|---|
| 1 | Phone |
| 2 | 555-0100 |
Formula: C2: =REPLACE(A2,1,3,"800")
Result: 800-0100
The first three characters are replaced by 800.
REPLACE with worked examples you can test in the live grid. The argument details are in the Excel guide.
The arguments and common errors are covered in the REPLACE Excel guide; check the function help in Google Sheets for its own argument list.
| A | |
|---|---|
| 1 | Phone |
| 2 | 555-0100 |
Formula: C2: =REPLACE(A2,1,3,"800")
Result: 800-0100
The first three characters are replaced by 800.
| A | |
|---|---|
| 1 | ID |
| 2 | AB1234 |
Formula: C2: =REPLACE(A2,3,0,"-")
Result: AB-1234
With num_chars at 0 nothing is removed, so the hyphen is inserted before position 3.
| A | |
|---|---|
| 1 | Label |
| 2 | Report 2024 |
Formula: C2: =REPLACE(A2,LEN(A2)-3,4,"2025")
Result: Report 2025
LEN(A2)-3 is the start of the year no matter how long the label is.
A tiny spreadsheet with example data. Edit the formula or any number and see the result.
Formula in D2: =REPLACE(A5,1,3,"ID")
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Text | Other | Result | |
| 2 | Alice Johnson | alice johnson | ID-2026-0415 | |
| 3 | [email protected] | [email protected] | ||
| 4 | extra spaces | |||
| 5 | SKU-2026-0415 | |||
| 6 | iced coffee, tea, sugar | |||
| 7 | Order 417 shipped |
Google Sheets is used here only as a descriptive product name. FormulaCamp is not affiliated with Google.
Enter — commit · F2 — edit · F4 — $ in a reference · Ctrl+C/Ctrl+V — copy and paste · Ctrl+Z — undo
Esc or F6 — leave the sheet for the «Check» button · Shift+Tab in the first cell — back to the page