How to Use the SUBSTITUTE Function in Excel

Today, we’ll explore the SUBSTITUTE function, a versatile tool available in both Microsoft Excel and Google Sheets. This function is designed to replace specified text within a cell with new text of your choice.

Basic Syntax

The syntax for the SUBSTITUTE function is straightforward:

=SUBSTITUTE(text, old_text, new_text, [instance_num])
  • text: The text string that contains the text you want to replace.
  • old_text: The substring that you wish to replace within the text.
  • new_text: The text that will replace the old_text.
  • instance_num (optional): This parameter specifies which occurrence of the old_text you wish to replace. If this parameter is omitted, all instances of old_text will be replaced.

Examples

Example 1: Simple Replacement

Assume we have the phrase “An apple a day keeps the doctor away.” in cell A1:

To substitute “apple” with “orange”, the formula is:

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

The result will be: “An orange a day keeps the doctor away.”

Example 2: Replacing Specific Occurrence

Using the optional instance_num parameter allows you to target a specific occurrence of old_text for replacement. Consider cell A1 contains: “David,John,Jacob,John,Sarah”.

To replace the second occurrence of “John” with “Emily”, the formula would be:

=SUBSTITUTE(A1, "John", "Emily", 2)

The result will be: “David,John,Jacob,Emily,Sarah”.

Example 3: Case-Insensitive Replacement

To achieve a case-insensitive replacement, you can combine the SUBSTITUTE function with LOWER or UPPER. For example:

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

This formula first converts all text in A1 to lowercase and then performs the substitution, effectively ignoring the original text’s case.

Conclusion

The SUBSTITUTE function offers a powerful way to modify specific text within cells in Excel and Google Sheets. By mastering its syntax and exploring practical examples, you’ll be able to manipulate text data more effectively and efficiently.

More information: https://support.microsoft.com/en-us/office/substitute-function-6434944e-a904-4336-a9b0-1e58df3bc332

Other functions
Returns an array of text values from any specified range
Changes full-width (double-byte) English letters or katakana within a character string to half-width (single-byte) characters
Converts a number to text, using the ß (baht) currency format
Returns the character specified by the code number
Removes all nonprintable characters from text
Returns a numeric code for the first character in a text string
Combines the text from multiple ranges and/or strings, but it doesn't provide the delimiter or IgnoreEmpty arguments
Joins several text items into one text item
Changes half-width (single-byte) English letters or katakana within a character string to full-width (double-byte) characters
Converts a number to text, using the $ (dollar) currency format
Checks to see if two text values are identical
Finds one text value within another (case-sensitive)
Formats a number as text with a fixed number of decimals
Changes half-width (single-byte) characters within a string to full-width (double-byte) characters
Returns the leftmost characters from a text value
Returns the number of characters in a text string
Converts text to lowercase
Returns a specific number of characters from a text string starting at the position you specify
Converts text to number in a locale-independent manner
Extracts the phonetic (furigana) characters from a text string
Capitalizes the first letter in each word of a text value
Replaces characters within text
Repeats text a given number of times
Returns the rightmost characters from a text value
Finds one text value within another (not case-sensitive)
Converts its arguments to text
Formats a number and converts it to text
Combines the text from multiple ranges and/or strings, and includes a delimiter you specify between each text value that will be combined If the delimiter is an empty text string, this function will effectively concatenate the ranges
Removes spaces from text
Returns the Unicode character that is references by the given numeric value
Returns the number (code point) that corresponds to the first character of the text
Converts text to uppercase
Converts a text argument to a number
Returns text from any specified value