Category: FUNCTION | Updated: 2026-11-22

How to Use the SUBSTITUTE Function in Google Sheets | Replace Specific Text Strings

How to Use the SUBSTITUTE Function

The SUBSTITUTE function searches for a specific character or word within a text string and replaces it with another string. By passing an empty string "" as the replacement, it is also widely used to delete unwanted symbols or spaces.

Syntax

=SUBSTITUTE(text_to_search, search_for, replace_with, [occurrence_number])
  • text_to_search: The original text string or cell reference to modify (required).
  • search_for: The substring you want to find and replace (required).
  • replace_with: The new text string to insert in place of search_for (required). Use "" to delete the matched text.
  • occurrence_number: When search_for appears multiple times, specifies which occurrence (e.g., 1, 2) to replace (optional). If omitted, all occurrences are replaced.

Example Using a Table

Here is an example of removing all hyphens - from phone numbers, as well as replacing only the second hyphen.

Row Column A (Raw Data) Column B (Remove All) Column C (Replace 2nd Only)
1 Raw Data Remove Hyphens Replace 2nd Only
2 03-1234-5678 =SUBSTITUTE(A2, "-", "") → 0312345678 =SUBSTITUTE(A2, "-", "_", 2) → 03-1234_5678
3 090-9999-0000 =SUBSTITUTE(A3, "-", "") → 09099990000 =SUBSTITUTE(A3, "-", "_", 2) → 090-9999_0000
  • Formula: =SUBSTITUTE(A2, "-", "")
  • Result: 0312345678

In Column C, where 2 is passed as the fourth argument, the first hyphen remains unchanged and only the second hyphen is replaced with _.

Common Errors and Notes

  • Case-Sensitive Matching: Searching for "abc" will not match or replace "ABC". If you need a case-insensitive replacement, use REGEXREPLACE with the (?i) flag.
  • occurrence_number Less Than 1 Causes #VALUE!: The fourth argument must be an integer of 1 or greater. Passing 0 or a negative number produces a #VALUE! error.
  • Empty search_for (""): No error occurs; the original text string is returned unchanged.

Frequently Asked Questions

Q. What is the difference between SUBSTITUTE and REPLACE?

A. SUBSTITUTE replaces a specific text string (such as a hyphen or company name), whereas REPLACE replaces text based on its position and length (e.g., a specified number of characters starting at a given position).

Q. Can SUBSTITUTE replace multiple different characters at once?

A. A single SUBSTITUTE call can only specify one search string. To remove or replace multiple characters (such as both hyphens and parentheses), nest multiple SUBSTITUTE calls or use REGEXREPLACE.