The SUBSTITUTE function
SUBSTITUTE finds some text inside a cell and replaces it. Swap dashes for slashes, delete spaces, or change an old product name to a new one.
It matches by content, not position. If you know *where* the text is rather than *what* it says, REPLACE is the tool for that.
=SUBSTITUTE(text, old_text, new_text, [instance_num])
Arguments
- text
- The text (or cell) to change.
- old_text
- The text to look for. The match is case-sensitive.
- new_text
- What to put in its place. Use
""to deleteold_text. - instance_numoptional
- Which occurrence to replace (1 for the first, 2 for the second…). Leave it out to replace every one.
Try it
=SUBSTITUTE(A2," ","") in C2. Every space is replaced with nothing, leaving 07700900123.
C2
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Phone | Date text | Digits only | |
| 2 | 07700 900 123 | 14-03-2025 | 07700900123 | |
| 3 | +44 7700 900456 | 02-06-2025 | ||
| 4 | ||||
| 5 | ||||
| 6 |
Edit the formula in C2, or change the data, and press Enter.
More examples
| Formula | Result | What it does |
|---|---|---|
| =SUBSTITUTE(A3,"+44 ","0") | 07700 900456 | Turn an international prefix into the UK leading zero. |
| =SUBSTITUTE(B2,"-","/") | 14/03/2025 | Swap every dash for a slash. |
| =SUBSTITUTE(B3,"-","/",2) | 02-06/2025 | With an instance number, only the second dash changes. |
| =LEN(A2)-LEN(SUBSTITUTE(A2," ","")) | 2 | Count the spaces: the length lost when they're removed. |
Tips
- Nest SUBSTITUTE to make several swaps:
=SUBSTITUTE(SUBSTITUTE(A2,"(",""),")","")removes both brackets. - Combine with LEN to count how many times something appears in a cell.
- Remove non-breaking spaces from web data with
SUBSTITUTE(A2,CHAR(160)," ").
Common mistakes
- Nothing is replaced.SUBSTITUTE is case-sensitive: "ltd" won't match "Ltd". Match the case exactly, or apply LOWER or UPPER first.
- An amount cleaned with SUBSTITUTE won't add up.The result is always text. Wrap it in VALUE:
=VALUE(SUBSTITUTE(A2,",","")). - You wanted to replace characters 3 to 5, whatever they say.That's a job for REPLACE, which works by position.
Practise SUBSTITUTE with instant feedback
Type real formulas into a working spreadsheet and get told straight away whether they work.