0
0
Google Sheetsspreadsheet~5 mins

SUBSTITUTE and REPLACE in Google Sheets - Step-by-Step Guide

Choose your learning style9 modes available
Introduction
These two formulas help you change text inside a cell. SUBSTITUTE replaces specific words or letters you choose. REPLACE changes part of the text based on position. They solve the problem of fixing or updating text without typing it all again.
When you want to change all occurrences of a word in a sentence, like fixing a repeated typo.
When you need to replace only the second or third occurrence of a word in a text.
When you want to change a part of a phone number or code by position, like changing area code digits.
When you want to update a product code by replacing certain characters at fixed positions.
When you want to remove or replace a specific word in a sentence without changing the rest.
Steps
Step 1: Click
- cell where you want the result
The cell is selected and ready for formula input
Step 2: Type
- the formula bar
Formula bar shows your typed formula
💡 Start with =SUBSTITUTE(text, old_text, new_text, [instance_num]) or =REPLACE(text, start_num, num_chars, new_text)
Step 3: For SUBSTITUTE, enter the text or cell reference as the first argument
- inside the parentheses
Formula knows which text to change
Step 4: Type the word or letter you want to replace as the second argument
- inside the parentheses after the first argument
Formula knows what to find in the text
Step 5: Type the new word or letter as the third argument
- inside the parentheses after the second argument
Formula knows what to replace the old text with
Step 6: Optionally, for SUBSTITUTE, type the instance number to replace only that occurrence
- inside the parentheses as the fourth argument
Only that specific occurrence is replaced
Step 7: For REPLACE, enter the text or cell reference as the first argument
- inside the parentheses
Formula knows which text to change
Step 8: Type the starting position number of the text to replace as the second argument
- inside the parentheses after the first argument
Formula knows where to start replacing
Step 9: Type how many characters to replace as the third argument
- inside the parentheses after the second argument
Formula knows how many characters to remove
Step 10: Type the new text to insert as the fourth argument
- inside the parentheses after the third argument
Formula replaces the specified characters with this new text
Step 11: Press Enter
- formula bar
Cell shows the updated text with replacements
Before vs After
Before
Cell A1 contains 'I love apples and apples are sweet'
After
Using =SUBSTITUTE(A1, "apples", "oranges") results in 'I love oranges and oranges are sweet'
Settings Reference
text
📍 first argument in SUBSTITUTE or REPLACE formula
The original text where replacements happen
Default: none
old_text
📍 second argument in SUBSTITUTE formula
The text you want to replace
Default: none
new_text
📍 third argument in SUBSTITUTE or fourth in REPLACE formula
The text to replace with
Default: none
instance_num
📍 optional fourth argument in SUBSTITUTE formula
Which occurrence of old_text to replace
Default: all occurrences replaced
start_num
📍 second argument in REPLACE formula
Position to start replacing characters
Default: none
num_chars
📍 third argument in REPLACE formula
Number of characters to replace starting at start_num
Default: none
Common Mistakes
Not using quotes around text strings in formulas
Google Sheets treats unquoted text as cell references, causing errors
Always put text strings inside double quotes, like "apples"
Using SUBSTITUTE without specifying instance_num when you want to replace only one occurrence
All occurrences get replaced, not just one
Add the fourth argument with the occurrence number, e.g., =SUBSTITUTE(A1, "apples", "oranges", 2)
Using REPLACE with wrong start_num or num_chars causing unexpected text changes
Formula replaces wrong part of text or deletes too much
Count characters carefully and test with small examples before applying
Summary
SUBSTITUTE replaces specific text by matching words or letters you choose.
REPLACE changes text based on position and length inside the string.
Remember to use quotes for text and count positions carefully for REPLACE.