Skip to content
Google Sheets

SUBSTITUTE function in Google Sheets

Replaces existing text with new text in a string.

=SUBSTITUTE(text_to_search, search_for, replace_with, [occurrence_number])

SUBSTITUTE syntax and parameters

Four arguments, three required.

  • text_to_searchstringRequired

    The text within which to search and replace.

  • search_forstringRequired

    The string to search for within text_to_search. search_for will match parts of words as well as whole words; therefore a search for "vent" will also replace text within "eventual".

  • replace_withstringRequired

    The string that will replace search_for.

  • occurrence_numbernumberOptional

    [ OPTIONAL ] - The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced.

SUBSTITUTE examples

Formulas you'll actually reuse.

  1. Strip the hyphens out of a phone number or SKU:

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

    Result"NYC10422"

  2. Replace only the first space — the fourth argument picks which occurrence:

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

    Result"Maria-Lopez Garcia"

SUBSTITUTE in Excel

Same name — your formula ports as-is.

Try SUBSTITUTE in the playground

Edit the example — nothing to install.

Preloaded with the SUBSTITUTE formula from Example 1 — change anything and watch it respond.

Loading the editor…