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.
Strip the hyphens out of a phone number or SKU:
=SUBSTITUTE(A2, "-", "")Result
"NYC10422"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.
Related functions
More ways Google Sheets gets this done.
- ARABICComputes the value of a Roman numeral.TextExcel
- CHARConvert a number into a character according to the current Unicode table.TextExcel
- CLEANReturns the text with the non-printable ASCII characters removed.TextExcel
- CODEReturns the numeric Unicode map value of the first character in the string provided.TextExcel
- CONCATENATEAppends strings to one another.TextExcel
- DOLLARFormats a number into the locale-specific currency format.TextExcel