Find and replace with SUBSTITUTE
These phone numbers were typed with dashes. Swap every dash for a space in column B.
keyboard Typing formulas is easiest on a computer with a keyboard.
| A | B | C | |
|---|---|---|---|
| 1 | Phone | With spaces | |
| 2 | 07700-900393 | ||
| 3 | 07700-900-168 | ||
| 4 | 07700-900683 | ||
| 5 | 07700-900351 | ||
| 6 | 07700-900-884 | ||
| 7 | 07700-900-980 | ||
| 8 | 07700-900413 | ||
| 9 | |||
| 10 | |||
| 11 | |||
| 12 |
How SUBSTITUTE works
What does
SUBSTITUTEdo?SUBSTITUTEis find and replace inside a formula. It swaps every copy of one piece of text for another:=SUBSTITUTE(A2,"-", " ") What are its parts?
- The text to change:
A2. - What to find, in double quotes:
"-". - What to put instead:
" ". Use""(two quotes, nothing between) to delete it. - Optional: which copy to replace.
=SUBSTITUTE(A2,"-"," ",2)only changes the second dash.
- The text to change:
Why not
TRIM?TRIMonly removes spaces at the start and end, and turns double spaces into single ones. The spaces in the middle of 07700 900 123 stay.SUBSTITUTEremoves every one.Is it case-sensitive?
Yes.
SUBSTITUTE(A2,"ltd","Ltd")won't touch "LTD". Use it onUPPERorLOWERof the text if the capitals vary.Why not Find and Replace (Ctrl+H)?
Ctrl+H changes the original data once.
SUBSTITUTEleaves the original alone and updates by itself when the data changes. It also works inside bigger formulas, for example to clean a value before a lookup.
Know someone fighting with a spreadsheet? Send them this page.