If you have a lot of similar text entries in a spreadsheet, you might want to replace a small part of each entry.
Doing this manually would be a nightmare so spreadsheets have functions to help.
One such function is the SUBSTITUTE function.
SUBSTITUTE
Within text data, SUBSTITUTE replaces a piece of text data with a different piece of text.
It can do this once at a nominated occurrence or for every instance in the data.
Syntax
- text_to_search = text (or cell reference with text data) that you want to replace text within
- search_for = case sensitive text (or cell reference with text data) that you want to search for within text_to_search
- replace_with = text (or cell reference with text data) that will replace search_for.
- [occurrence_number] = optional setting to replace only the occurrence number provided (e.g. if search_for appears in text_to_search twice, only the nominated occurrence will be replaced). By default the function replaces all occurrences.
Example
You want to replace the word "fun" with "awesome" in the text:
This function is fun!
Output: This awesomection is awesome!
That doesn’t look right.
You have to be careful when using SUBSTITUTE as it’s indiscriminate.
It will replace search_for even when it is part of another word.
When search_for is "fun", it’s found twice:
This function is fun!
This is where the optional [occurrence_number] argument could be used to specify that the function should only change the second "fun".
Alternatively, you could make your formula more specific by including the exclamation point:
Both of these options output:
This function is awesome!
A | B | C | |
1 | Dwight L. Chang | ||
2 | Dwight Fart Schrute | ||
3 | Kelly and Kelly | ||
4 |
FREE RESOURCE
Google Sheets Cheat Sheet
12 exclusive tips to make user-friendly sheets from today:
You'll get updates from me with an easy-to-find "unsubscribe" link.