Text function

SUBSTITUTE function

Replaces every occurrence (or one chosen occurrence) of a specific text with new text. Case-sensitive.

Available in All versions of Excel, including Microsoft 365, Excel for Mac and Excel for the web

In every Excel versionWorks in Google Sheets

Syntax

SUBSTITUTE(text, old_text, new_text, [instance_num])
ArgumentWhat it means
textRequiredThe text or cell to change.
old_textRequiredThe exact text to find. Case matters.
new_textRequiredThe text to put in its place. "" deletes old_text.
instance_numOptionalWhich occurrence to replace (1 = first, 2 = second ...). Omit it to replace all of them.

Returns: The text with the replacements made.

How SUBSTITUTE works

SUBSTITUTE is Excel's find-and-replace in formula form. It looks for an exact piece of text and swaps it for another, everywhere it appears: =SUBSTITUTE(A2,"-","") removes all hyphens from a phone number, =SUBSTITUTE(A2,"St.","Street") expands abbreviations. Unlike the Replace dialog (Ctrl+H) it leaves the original data untouched and updates automatically when the data changes.

The optional fourth argument replaces only one specific occurrence: instance_num 2 changes the second match and leaves the others. SUBSTITUTE is case-sensitive, so "st." will not replace "St."; it does not support wildcards. To change several different things, nest SUBSTITUTE calls inside each other.

A classic trick uses SUBSTITUTE to count: the length of a text minus the length of the same text with every comma removed equals the number of commas. Use REPLACE when you know the position rather than the content, and REGEXREPLACE for pattern-based replacements in Microsoft 365.

Examples

1Remove hyphens from phone numbers

B2fx=SUBSTITUTE(A2,"-","")
AB
1Contact
2Phone: 210-555-0147Phone: 2105550147

Result: Phone: 2105550147

Every hyphen is replaced with an empty string; the rest of the text is unchanged.

2Replace only the second occurrence

B2fx=SUBSTITUTE(A2,"-","/",2)
AB
1Date (text)
22026-03-152026-03/15

Result: 2026-03/15

With instance_num 2 only the second hyphen becomes a slash.

3Count items in a list

B2fx=LEN(A2)-LEN(SUBSTITUTE(A2,",",""))+1
AB
1Order items
2pens, paper, ink, toner4

Result: 4

Removing the commas makes the text 3 characters shorter, so there are 3 commas and therefore 4 items.

4Several replacements at once

B2fx=SUBSTITUTE(SUBSTITUTE(A2,"St.","Street"),"Rd.","Road")
AB
1Address
212 Baker St., Mill Rd.12 Baker Street, Mill Road

Result: 12 Baker Street, Mill Road

The inner SUBSTITUTE expands St.; the outer one then expands Rd. in the result.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 17 KB

Common errors and how to fix them

ErrorWhy it happensFix
#VALUE!instance_num is 0 or negative.Use 1 or higher, or leave it out to replace every occurrence.

Tips

  • SUBSTITUTE is case-sensitive. For a case-insensitive replacement use REGEXREPLACE with case_sensitivity 1, or convert the text with LOWER first.
  • =SUBSTITUTE(A2,CHAR(160)," ") fixes non-breaking spaces from web data that TRIM cannot remove.
  • SUBSTITUTE on a number returns text; wrap in VALUE to get a number back, e.g. =VALUE(SUBSTITUTE(A2,"$","")).

Questions

What is the difference between SUBSTITUTE and REPLACE?

SUBSTITUTE swaps a known piece of text wherever it is. REPLACE swaps whatever is at a given position.

How do I make several replacements in one formula?

Nest the calls: =SUBSTITUTE(SUBSTITUTE(A2,"a","b"),"c","d"). In Microsoft 365, REDUCE with LAMBDA can apply a whole replacement table.

Can SUBSTITUTE use wildcards?

No, it only replaces exact text. Use REGEXREPLACE for patterns.

Google Sheets

SUBSTITUTE also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

SUBSTITUTE in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
CzechDOSADIT
DanishUDSKIFT
DutchSUBSTITUEREN
FinnishVAIHDA
FrenchSUBSTITUE
GermanWECHSELN
HungarianHELYETTE
ItalianSOSTITUISCI
Norwegian (Bokmål)BYTT.UT
PolishPODSTAW
Portuguese (Brazil)SUBSTITUIR
Portuguese (Portugal)SUBST
RussianПОДСТАВИТЬ
SpanishSUSTITUIR
SwedishBYT.UT
TurkishYERİNEKOY

Recipes that use SUBSTITUTE