Excel functions / Text

SUBSTITUTE

Replaces one piece of text with another everywhere it appears.

Syntax=SUBSTITUTE(text, old_text, new_text, [instance_num])

Arguments

textThe text to change.
old_textWhat to replace.
new_textWhat to put instead. Use "" to delete it.
instance_numOptional. Replace only this occurrence.

How it works

SUBSTITUTE swaps text by content, not position. It is ideal for cleaning data: removing dashes from codes, swapping full stops for commas, or deleting a unit from "25 kg".

Replacing something with empty quotes deletes it: =SUBSTITUTE(A2,"-","").

Example

C2=SUBSTITUTE(A2,"-","")
ABC
1Phone
2555-0142-77555014277
3

Result: 555014277. Both dashes are removed.

Tips

Practise SUBSTITUTE

Try it yourself in a real spreadsheet, with instant feedback on every answer.

Start the exercise

Related