Startseite Β» Excel EN Β» Excel SUBSTITUTE Function πŸ“ | Replace Text Smartly

Excel SUBSTITUTE Function πŸ“ | Replace Text Smartly

Introduction to the SUBSTITUTE Function in Excel

The SUBSTITUTE function in Excel is one of the most practical tools for anyone working with text data. Whether you are cleaning up customer information, fixing inconsistent labels, or modifying values in large data sets, SUBSTITUTE offers a fast and flexible way to replace specific parts of a text string πŸ“.

It works flawlessly on Windows, macOS, and even on Ubuntu through LibreOffice Calc, giving it broad accessibility and ease of use.


What the SUBSTITUTE Function Does

The SUBSTITUTE() function lets you replace text within a string. You can change all occurrences or just a specific one. Unlike REPLACE() which changes text based on position, SUBSTITUTE() replaces text by value.

Perfect for:

  • Correcting misspellings
  • Removing unwanted characters
  • Replacing codes or abbreviations
  • Formatting values consistently

Syntax of the SUBSTITUTE Formula

=SUBSTITUTE(text, old_text, new_text, [instance_num])
  • text: The original string
  • old_text: The part to replace
  • new_text: What to replace it with
  • instance_num (optional): Replaces only that occurrence

Example:

=SUBSTITUTE("apple apple", "apple", "orange")

Returns: orange orange

Or:

=SUBSTITUTE("apple apple", "apple", "orange", 2)

Returns: apple orange


SUBSTITUTE vs REPLACE in Excel

FeatureSUBSTITUTEREPLACE
Based onValue (text match)Character position
Replace AllYes, by defaultNo, only exact positions
Replace SpecificYes, using instance_numNot applicable
Use caseText cleanup, correctionsStructured formats, codes

πŸ”Ž Use SUBSTITUTE when you know what to replace
πŸ”§ Use REPLACE when you know where to replace


Example 1: Replacing Words in a Sentence

Text in A1:

Welcome to Paris. Paris is beautiful.

Formula:

=SUBSTITUTE(A1, "Paris", "London")

Result:

Welcome to London. London is beautiful.

Want to replace only the second occurrence?

=SUBSTITUTE(A1, "Paris", "London", 2)

Result:

Welcome to Paris. London is beautiful.

Example 2: Fixing Data with SUBSTITUTE

Product codes like:

ABC-123, ABC-124, ABC-125

You want to replace “ABC” with “XYZ”:

=SUBSTITUTE(A1, "ABC", "XYZ")

Works perfectly for SKU updates or version changes in product sheets.


Using SUBSTITUTE with Cell References

A (Text)B (Find)C (Replace)Formula
“Red Shirt”“Red”“Blue”=SUBSTITUTE(A1, B1, C1)
“Red Hat”“Red”“Green”=SUBSTITUTE(A2, B2, C2)

This allows dynamic replacement with variables from your worksheet.


Replacing Specific Occurrences Only

If a value appears multiple times:

=SUBSTITUTE("AAABBBCCC", "B", "X", 2)

Result: AAABXBCC

Only the second B is replaced.

Great for cleaning up inconsistent patterns in long strings.


Nesting SUBSTITUTE with TEXT and CONCAT

You can build formatted strings:

="Invoice: " & SUBSTITUTE(A1, "-", "/")

Or with TEXT():

="Order Date: " & TEXT(TODAY(), "mmm dd") & " | Ref: " & SUBSTITUTE(A2, " ", "-")

πŸ“‹ Makes report entries and filenames more consistent


SUBSTITUTE on Windows

  • Use F2 to edit and preview formulas
  • Compatible with Excel 2007 and newer
  • Press Ctrl + Enter to apply formula to selected cells

πŸ–₯️ Best used with auto-fill and structured tables


SUBSTITUTE on macOS

  • Use Control + U to edit formulas
  • Same formula syntax and function as Windows
  • Fully supported in Excel for Mac 2016 and newer

🍏 Ideal for Apple-based data analysis and formatting


SUBSTITUTE in LibreOffice on Ubuntu

LibreOffice Calc supports:

=SUBSTITUTE("Item_XYZ", "_", "-")
  • Function behaves just like Excel
  • No compatibility issues across most Linux distros
  • Perfect for developers and data scientists on Ubuntu 🐧

Formatting Output from SUBSTITUTE

To keep data clean:

  • Use TRIM() if replacement adds unwanted spaces
  • Use UPPER() or LOWER() for consistent case
  • Wrap with TEXT() when merging into messages or file names

Example:

=UPPER(SUBSTITUTE(A1, "error", "issue"))

Handling Common Errors with SUBSTITUTE

ErrorCauseFix
#VALUE!Non-text inputEnsure all arguments are text strings
No changeIncorrect old_text formatMatch case or spacing correctly
Extra spacesReplacing ” ” with “” might collapse textAdd spacing manually if needed

Use IFERROR() for fallback text:

=IFERROR(SUBSTITUTE(A1, "Old", "New"), "Check Input")

Combining SUBSTITUTE with IF or LEN

Example: Replace only if string is longer than 10 characters

=IF(LEN(A1)>10, SUBSTITUTE(A1, "ABC", "DEF"), A1)

Useful for conditional text edits in large datasets or dashboards


SUBSTITUTE with Wildcards or Numbers

SUBSTITUTE treats the entire match literally
It does not support wildcards like * or ?

But you can still replace numbers:

=SUBSTITUTE("Order1234", "1234", "5678")

Cleaning Imported Data with SUBSTITUTE

Many files from external sources contain:

  • Extra quotes
  • Commas instead of dots
  • Inconsistent delimiters

Use SUBSTITUTE to clean them:

=SUBSTITUTE(A1, ",", ".")

or

=SUBSTITUTE(A1, """", "")

πŸ“Š Helps in preparing data for analysis and export


Creating Templates with SUBSTITUTE

You can create reusable tools like:

  • Email generators
  • Invoice ID correctors
  • File renamers
  • Address normalizers

Just point SUBSTITUTE to input cells and apply rules dynamically.


FAQs About Excel SUBSTITUTE Function

What does the SUBSTITUTE function do in Excel?
It replaces a specific substring with another string inside a larger text.

Is SUBSTITUTE case-sensitive?
Yes. “apple” and “Apple” are treated as different strings.

Can SUBSTITUTE replace just one occurrence?
Yes, use the optional fourth argument to select which instance to replace.

Does SUBSTITUTE work in macOS and Ubuntu?
Absolutely. It works the same on Excel for Mac and in LibreOffice Calc on Ubuntu.

How is SUBSTITUTE different from REPLACE?
SUBSTITUTE replaces based on text value. REPLACE works on position.


Final Thoughts on SUBSTITUTE in Excel

The SUBSTITUTE function in Excel is a versatile and reliable tool that simplifies text correction, formatting, and data cleanup. Whether you’re processing product names, customer notes, or importing messy datasets, SUBSTITUTE provides pinpoint control over string manipulation.

Supported across Windows, macOS, and Ubuntu, it’s an essential function for anyone working in data management or spreadsheet automation 🧠

Master it once, and you’ll find countless ways to simplify your workflow.

Complete List of Windows Keyboard Shortcuts

If you need help for Windows, you can find a whole list of all keyboard shortcuts here.

https://keyboard-shortcuts.org/

Advertisment