SUBSTITUTE
Replaces specific text within a string. Useful for cleaning or transforming data.
SUBSTITUTE(text, old_text, new_text, [instance_num])Arguments
textThe text containing text to replaceold_textThe text to find and replacenew_textThe replacement textinstance_numWhich occurrence to replace (all if omitted)(optional)
=SUBSTITUTE("Hello World","World","Excel")Replaces 'World' with 'Excel'
=SUBSTITUTE(A1," ","")Removes all spaces
=SUBSTITUTE(A1,"-","/",1)Replaces only first dash
- •Case-sensitive - 'A' and 'a' are different
- •Replaces all occurrences unless instance_num specified
- •Use REPLACE for position-based replacement
- •Confusing SUBSTITUTE with REPLACE - SUBSTITUTE matches text by content, REPLACE matches by character position, and picking the wrong one leads to replacing the wrong occurrence or none at all
- •Forgetting that SUBSTITUTE is case-sensitive when matching old_text, so SUBSTITUTE("Excel","excel","Sheets") makes no replacement at all since the case doesn't match
- •Omitting the optional instance_num argument when only one specific occurrence should change, causing SUBSTITUTE to replace every matching occurrence in the string instead of just the intended one
REPLACEReplaces text based on a fixed starting position and length rather than by matching the text itself.FINDLocates the position of text within a string, useful for determining instance_num values before using SUBSTITUTE.TRIMOften paired with SUBSTITUTE to remove specific unwanted characters, like non-breaking spaces, that TRIM alone won't catch.What's the difference between SUBSTITUTE and REPLACE?
SUBSTITUTE finds and replaces text by matching its content, while REPLACE swaps out characters based on a starting position and length you specify - use SUBSTITUTE when you know the text to find, REPLACE when you know exactly where it sits.
Is SUBSTITUTE case-sensitive?
Yes, old_text must match the case in the source text exactly, or no replacement happens.
How do I replace only the second occurrence of a word?
Add the instance_num argument, like SUBSTITUTE(A1,"cat","dog",2), which replaces only the second occurrence and leaves the rest untouched.
Need to translate a formula using SUBSTITUTE?
Use our translator to convert your complete formula
