How to Use the SUBSTITUTE Function in Microsoft Excel

Cleaning up inconsistent data is one of the most common tasks in Microsoft Excel. If you receive a spreadsheet where an employee accidentally typed “Teh” instead of “The” 50 times, or a product catalog where half the items are labeled “Red” and you need them to say “Crimson,” you need a fast way to swap that text.

While the Find & Replace tool (Ctrl+H) works great for a one-time sweep, it alters your original data. If you want a formula-based approach that leaves your original data intact and updates automatically when new data is added, you should use the SUBSTITUTE function.

Understanding the Syntax

The SUBSTITUTE function scans a cell for a specific string of text and swaps it out with a new string of text.

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

  • text: The cell containing the data you want to change (e.g., A2).
  • old_text: The exact text you want to find and remove. (Must be in quotes).
  • new_text: The text you want to insert in its place. (Must be in quotes).
  • instance_num: (Optional) If the word appears multiple times, this tells Excel which specific one to change. If you leave this blank, it changes every single occurrence.

Basic Example: Swapping a Word

Imagine cell A2 contains the phrase: The quick brown fox. You want to change “brown” to “red”.

  1. Click on an empty cell next to it (e.g., B2).
  2. Type the formula: =SUBSTITUTE(A2, "brown", "red")
  3. Press Enter.

Cell B2 will instantly display: The quick red fox.

Important Warning: The SUBSTITUTE function is strictly case-sensitive. If you wrote "Brown" with a capital B in the formula, Excel would find no match in the original sentence and would change nothing.

Advanced Example: Removing Spaces from Phone Numbers

A brilliant trick for the SUBSTITUTE function is using it to delete characters entirely, which is incredibly useful for formatting phone numbers or ID codes.

Imagine cell A2 contains a poorly formatted phone number: (555) 123 - 4567. You want to remove all the blank spaces.

  1. Type the formula: =SUBSTITUTE(A2, " ", "")
  2. Press Enter.

In this formula, the old_text is a single space (" "). The new_text is absolutely nothing (""). Excel will scan the phone number, find every space, and replace them with nothing, leaving you with (555)123-4567.

Using the Instance Number

What if you only want to change a specific occurrence of a word, not all of them?

Imagine cell A2 contains a product code: PART-2023-PART-B. You only want to change the first instance of the word “PART” to “ITEM”, but leave the second one alone.

You would use the optional fourth argument:

=SUBSTITUTE(A2, "PART", "ITEM", 1)

Because you put a “1” at the end, Excel will only swap out the very first “PART” it finds, resulting in: ITEM-2023-PART-B.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.

Receive our best articles and tips delivered straight to your inbox.