0Pricing
Excel Formulas Academy · Lesson

Replacing Text With SUBSTITUTE

Swap out characters or words inside a string with SUBSTITUTE.

Replacing Text With SUBSTITUTE is a free Excel Formulas Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Excel Formulas Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

The Need to Replace Text

Data often needs find-and-replace inside formulas: stripping dashes from phone numbers, swapping a word, or removing stray symbols.

The SUBSTITUTE function finds a piece of text inside a cell and replaces every occurrence with new text, all without changing the original cell.

It is the formula-based equivalent of Find & Replace, but it updates automatically as your data changes.

The SUBSTITUTE Syntax

SUBSTITUTE takes up to four arguments:

  • text the original string or cell
  • old_text the text to find
  • new_text the text to put in its place
  • instance_num (optional) which occurrence to replace

The shape is =SUBSTITUTE(text, old_text, new_text, [instance_num]). If you omit the last argument, all occurrences are replaced.

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

Removing Characters

A common trick is replacing something with nothing to delete it. You do this by setting new_text to an empty string "".

If A2 holds 555-123-4567, the formula below removes every dash, returning 5551234567.

This pattern cleans phone numbers, IDs, and other punctuated values.

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

Swapping One Word for Another

SUBSTITUTE works on whole words too, not just single characters.

If A2 holds Annual report 2023, you can update the year by replacing the word:

The result is Annual report 2024. Every matching occurrence in the cell is changed.

=SUBSTITUTE(A2, "2023", "2024")

SUBSTITUTE Is Case-Sensitive

Important: SUBSTITUTE matches text exactly, including capitalization.

If A2 holds Cat cat CAT, then =SUBSTITUTE(A2, "cat", "dog") only changes the lowercase cat, giving Cat dog CAT.

If you need case-insensitive replacing, first normalize the case with LOWER or UPPER, or use the next lesson's regex functions in Sheets.

=SUBSTITUTE(A2, "cat", "dog")

Replacing Only One Occurrence

The optional fourth argument, instance_num, lets you target a single occurrence instead of all of them.

If A2 holds a-b-c-d and you only want to change the second dash, set instance_num to 2.

The result is a-b/c-d: only the second dash became a slash.

=SUBSTITUTE(A2, "-", "/", 2)

Worked Example: Cleaning Numbers

Imagine an imported amount stored as text: $1,250.00. To turn it into a usable number you must strip the dollar sign and the comma.

Nest two SUBSTITUTE calls, one inside the other, to remove both characters.

The inner call removes the comma; the outer call removes the dollar sign, leaving 1250.00.

=SUBSTITUTE(SUBSTITUTE(A2, ",", ""), "$", "")

Chaining Several Replacements

You can nest as many SUBSTITUTE calls as you need, each cleaning a different character.

To normalize a messy code that contains spaces, dots, and slashes into clean dashes, chain three substitutions.

Each layer feeds its result into the next, building up the final cleaned string.

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2, " ", "-"), ".", "-"), "/", "-")

SUBSTITUTE vs REPLACE

Do not confuse SUBSTITUTE with the similar REPLACE function.

  • SUBSTITUTE replaces text by matching its content (find this word, swap it).
  • REPLACE replaces text by position (replace 4 characters starting at position 5).

Use SUBSTITUTE when you know what to find, and REPLACE when you know where it sits.

=SUBSTITUTE(A2, "old", "new")

Counting Occurrences With SUBSTITUTE

A clever bonus: combine SUBSTITUTE with LEN to count how many times something appears.

Subtract the length after removing a character from the original length. If A2 holds a,b,c,d, this counts the commas, returning 3.

This trick is great for counting items in a delimited list.

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

Real Task: Standardizing Phone Formats

Suppose A2 holds messy numbers with dots and spaces like 555.123 4567. You want a consistent dashed format 555-123-4567.

First strip the dots and spaces, then you could re-insert dashes; for now, simply unify the separators to dashes.

Nesting substitutions standardizes whatever junk separators appear.

=SUBSTITUTE(SUBSTITUTE(A2, ".", "-"), " ", "-")

Quick Check

Test your understanding of SUBSTITUTE.

Recap: Replacing Text With SUBSTITUTE

You learned to find and replace text in formulas:

  • =SUBSTITUTE(text, old_text, new_text, [instance_num])
  • Use "" as new_text to delete characters.
  • It is case-sensitive; normalize case first if needed.
  • The optional instance_num targets a single occurrence.
  • Nest calls to clean multiple characters; pair with LEN to count occurrences.

You have completed Joining and Changing Text. Great work building clean, consistent data!

Frequently asked questions

Is the “Replacing Text With SUBSTITUTE” lesson free?

Yes — the full text of “Replacing Text With SUBSTITUTE” is free to read here on the web, and the Excel Formulas Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Excel Formulas Academy course, upgrade to CoddyKit PRO.

What will I learn in “Replacing Text With SUBSTITUTE”?

Swap out characters or words inside a string with SUBSTITUTE. You practise Excel Formulas Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Excel Formulas Academy?

No prior experience is required. Excel Formulas Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Replacing Text With SUBSTITUTE” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Excel Formulas Academy lesson?

Yes. Every Excel Formulas Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Merging Text With CONCAT
  2. Joining With Separators Using TEXTJOIN
  3. Changing Case With UPPER, LOWER, PROPER
  4. Replacing Text With SUBSTITUTE
← Back to Excel Formulas Academy