SUBSTITUTE
Replace specific text inside a string with new text using Excel's SUBSTITUTE function, matching by content rather than position.
Spreadsheet editor
Spreadsheet editor
Syntax
=SUBSTITUTE(text, old_text, new_text, [instance_num])
Returns: Text Arguments
| Argument | Required | Description |
|---|---|---|
| text | Yes | The original text string where substitutions will be made. |
| old_text | Yes | The text to be replaced in the original text string. |
| new_text | Yes | The text that will replace the old_text. |
| instance_num | No | The occurrence number of old_text to be substituted. If omitted, all occurrences will be replaced. |
About
Use SUBSTITUTE to clean and reshape text: update an email domain after a rebrand, remove thousands separators before converting to a number, or swap product-code separators. Because it matches on the actual characters, it works no matter where the text sits in the cell. Keep in mind that matching is case-sensitive, so "USA" and "usa" are treated as different.
Reach for SUBSTITUTE when you know the text you want to replace. If you instead know the position (replace 3 characters starting at character 5), use REPLACE. To locate text first, pair it with FIND or SEARCH, and use TRIM to tidy up leftover spaces.
Exercises using SUBSTITUTE
The Substitute function
BeginnerOpen exercise
Clean phone numbers
IntermediateStandardize phone numbers by removing parentheses, dashes, and spaces.
Open exerciseClean and standardize names
AdvancedStandardize company names (remove Inc/LLC/Corp, handle "The", title case).
Open exerciseComplex text parsing
AdvancedParse inconsistently formatted addresses into separate columns (street, city, state, zip).
Open exerciseExamples
Watch out for case-sensitive matches
Spreadsheet editor
Turn text amounts into real numbers
Spreadsheet editor
Watch out for
Confusing it with REPLACE
SUBSTITUTE swaps text by what it says, while REPLACE swaps by position. Reaching for the wrong one leads to characters changing in places you did not expect.
→ Use SUBSTITUTE when you know the text to find, and use REPLACE when you know the start position and length.
Nothing changes and no error appears
If old_text is not found, SUBSTITUTE returns the original string untouched, which can look like the formula failed.
→ Check for hidden spaces or mismatched characters. Run TRIM on the cell, and confirm the exact spelling and case of old_text.
Replacing every match by accident
Leave out the instance number and SUBSTITUTE changes all occurrences, which is a problem when only one should change.
→ Add the optional instance_num argument to target a single occurrence, such as the second comma or the first dash.