What is the SUBSTITUTE function?
=SUBSTITUTE(text, old_text, new_text, [instance_num])SUBSTITUTE finds specific characters in a text and replaces them with others. It is widely used to clean data, such as changing date separators or removing hyphens and spaces.
Leave out instance_num to replace every match; give a number to replace only that occurrence. Clicking a character in the strip above sets instance_num to its order.
Arguments
- text
- The text or cell containing the characters to replace.
- old_text
- The text to replace. It is case-sensitive.
- new_text
- The text to put in its place. "" (empty text) removes the matches.
- instance_num
- Optional. Which occurrence to replace.
SUBSTITUTE examples
Example 1. Change a separator
=SUBSTITUTE("2026-11-17", "-", "/")"2026/11/17".
Example 2. Replace only the second
=SUBSTITUTE("2026-11-17", "-", "/", 2)"2026-11/17".
Example 3. Remove hyphens
=SUBSTITUTE("2026-11-17", "-", "")"20261117".
Example 4. Example from Microsoft
=SUBSTITUTE("Quarter 1, 2011", "1", "2", 3)Only the third "1" changes: "Quarter 1, 2012".
Common mistakes
Replacing by position
To change characters at a given position, use REPLACE. SUBSTITUTE finds characters by content.
Case differences
"Sales" and "sales" are treated as different text.
FAQ
- Replace several things at once?
- Nest SUBSTITUTE: =SUBSTITUTE(SUBSTITUTE(A2,"-",""),"/","")
- What if old_text is not found?
- The original text is returned unchanged.