SUBSTITUTE Function

Replaces every occurrence (or a chosen one) of some text with new text.

Category

Text

Available in

All versions, Microsoft 365

Returns

Text

Taught hands-on in Level 4: Advanced Dynamic Arrays & Logic - Advanced Math & Text module

Overview

SUBSTITUTE finds specific text and swaps it for something else — every time it appears, or just the occurrence you pick.

It's a formula version of Find & Replace, and a building block for counting characters and words.

Syntax

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

Arguments

ArgumentRequired?What it does
textYesThe original text.
old_textYesThe text to replace. Case-sensitive.
new_textYesWhat to put in its place. "" removes it.
instance_numOptionalWhich occurrence to replace. Leave it out to replace them all.

Examples

Example 1 — Renaming a company

Northstar changed its legal suffix from Ltd to Inc.

B2fx=SUBSTITUTE(A2, "Ltd", "Inc")
AB
1OldNew
2Northstar LtdNorthstar Inc
3Northstar Ltd – WestNorthstar Inc – West
4Supplier CoSupplier Co
=SUBSTITUTE(A2, "Ltd", "Inc") Explain

Example 2 — Only the second dash

Change the second dash in a SKU to a slash.

B2fx=SUBSTITUTE(A2, "-", "/", 2)
AB
1SKUResult
2NS-1042-BLUNS-1042/BLU
3NS-2210-REDNS-2210/RED
=SUBSTITUTE(A2, "-", "/", 2) Explain

Example 3 — Counting a character

How many commas are in a cell? Compare the length with and without them.

=LEN(A2)-LEN(SUBSTITUTE(A2, ",", "")) Explain

Common mistakes

  • Case-sensitive. SUBSTITUTE won't touch “LTD” when you ask for “Ltd”. Nest two SUBSTITUTEs or use REGEXREPLACE with case-insensitive matching.

Notes

Kyle Stott

Author

Kyle Stott

Certified Microsoft Excel Expert

Kyle has worked professionally with Microsoft Excel for over a decade and has consulted on and taught Excel best practices to over 400 companies across 30+ countries.