Find and fix text errors in product codes by replacing wrong parts or substituting repeated words.
Sample Data
Row
Product Code
Description
2
AB123XX45
Blue Shirt Shirt
3
CD456YY78
Red Pants Pants
4
EF789ZZ90
Green Hat
5
GH012XX34
Yellow Shirt Shirt
6
IJ345YY67
Black Pants
Dashboard Components
KPI Card 1: Corrected Product Code (Replace wrong "XX" or "YY" with "00") =IF(ISNUMBER(SEARCH("XX", B2)), REPLACE(B2, SEARCH("XX", B2), 2, "00"), IF(ISNUMBER(SEARCH("YY", B2)), REPLACE(B2, SEARCH("YY", B2), 2, "00"), B2)) Shows product codes with "XX" or "YY" replaced by "00".
KPI Card 2: Clean Description (Remove repeated word "Shirt" or "Pants" once) =SUBSTITUTE(C2, " Shirt", "", 1) for "Shirt" rows and =SUBSTITUTE(C2, " Pants", "", 1) for "Pants" rows. Removes the second repeated word.
Table: Shows original and corrected product codes and descriptions side by side. Columns: - Original Product Code (B2:B6) - Corrected Product Code (formula above) - Original Description (C2:C6) - Clean Description (formula above)
Add a filter to select product codes containing "XX" or "YY". When filtered, KPI Card 1 updates to show only corrected codes for those filtered rows. The tables also update to show only filtered rows with original and corrected data. KPI Card 2 updates descriptions accordingly.
Self Check
If you add a filter to show only product codes containing "XX", which rows appear and how do the corrected product codes look?
Answer: Rows 2 and 5 appear. The corrected product codes replace "XX" with "00", so "AB123XX45" becomes "AB1230045" and "GH012XX34" becomes "GH0120034".
Key Result
Dashboard fixes product codes by replacing wrong parts and cleans repeated words in descriptions using SUBSTITUTE and REPLACE.
Practice
(1/5)
1. What does the SUBSTITUTE function do in Google Sheets?
easy
A. It formats cells with colors.
B. It changes text based on position and length.
C. It adds numbers together.
D. It replaces specific text by matching exact words or letters.
Solution
Step 1: Understand SUBSTITUTE purpose
The SUBSTITUTE function looks for specific text and replaces it exactly where it matches.
Step 2: Compare with REPLACE
Unlike REPLACE, SUBSTITUTE does not use position but matches text content.
Final Answer:
It replaces specific text by matching exact words or letters. -> Option D
Quick Check:
SUBSTITUTE = Replace by matching text [OK]
Hint: SUBSTITUTE changes text by matching words, not positions [OK]
Common Mistakes:
Confusing SUBSTITUTE with REPLACE
Thinking SUBSTITUTE works by position
Assuming SUBSTITUTE changes numbers
2. Which of these is the correct syntax for the REPLACE function in Google Sheets?
easy
A. REPLACE(text, start_num, num_chars, new_text)
B. REPLACE(text, old_text, new_text)
C. REPLACE(old_text, new_text, instance_num)
D. REPLACE(text, new_text, start_num)
Solution
Step 1: Recall REPLACE syntax
REPLACE requires the original text, the start position, number of characters to replace, and the new text.
Step 2: Check options
Only REPLACE(text, start_num, num_chars, new_text) matches this order and parameters correctly.
Final Answer:
REPLACE(text, start_num, num_chars, new_text) -> Option A
Quick Check:
REPLACE syntax = text, start, length, new text [OK]
Hint: REPLACE needs position and length, SUBSTITUTE needs old text [OK]
Common Mistakes:
Mixing parameter order
Using old_text instead of start_num
Omitting number of characters to replace
3. Given cell A1 contains the text "apple banana apple", what is the result of =SUBSTITUTE(A1, "apple", "orange", 2)?
medium
A. "orange banana orange"
B. "orange banana apple"
C. "apple banana orange"
D. "apple banana apple"
Solution
Step 1: Understand SUBSTITUTE with instance number
The formula replaces only the 2nd occurrence of "apple" with "orange".
Step 2: Apply replacement
First "apple" stays, second "apple" changes to "orange" resulting in "apple banana orange".
Final Answer:
"apple banana orange" -> Option C
Quick Check:
SUBSTITUTE replaces 2nd 'apple' only [OK]
Hint: Use 4th SUBSTITUTE argument to replace specific occurrence [OK]
Common Mistakes:
Replacing all occurrences instead of one
Replacing first occurrence by mistake
Confusing SUBSTITUTE with REPLACE
4. You want to replace the first 3 letters of the text in cell B2 with "XYZ". Which formula fixes the error in this incorrect formula: =SUBSTITUTE(B2, 1, 3, "XYZ")?
medium
A. =REPLACE(B2, "1", "3", "XYZ")
B. =REPLACE(B2, 1, 3, "XYZ")
C. =SUBSTITUTE(B2, "1", "XYZ", 3)
D. =SUBSTITUTE(B2, 3, 1, "XYZ")
Solution
Step 1: Identify misuse of SUBSTITUTE
SUBSTITUTE does not use position or length, so it cannot replace by position.
Step 2: Use REPLACE for position-based replacement
REPLACE takes start position, length, and new text, so =REPLACE(B2, 1, 3, "XYZ") is correct.
Final Answer:
=REPLACE(B2, 1, 3, "XYZ") -> Option B
Quick Check:
Use REPLACE for position-based text changes [OK]
Hint: Use REPLACE to change text by position, not SUBSTITUTE [OK]
Common Mistakes:
Using SUBSTITUTE with numbers as positions
Swapping parameters order
Using quotes incorrectly around numbers
5. You have a list of product codes in column A like "AB12345". You want to replace the first two letters with "X5" and also replace all occurrences of "5" with "9" in the same formula. Which formula achieves this?
hard
A. =SUBSTITUTE(REPLACE(A1, 1, 2, "X5"), "5", "9")
B. =REPLACE(SUBSTITUTE(A1, "5", "9"), 1, 2, "X5")
C. =SUBSTITUTE(A1, LEFT(A1, 2), "X5")
D. =REPLACE(A1, 1, 2, "X5") & SUBSTITUTE(A1, "5", "9")
Solution
Step 1: Replace first two letters with REPLACE
REPLACE(A1, 1, 2, "X5") changes first two letters to "X5".
Step 2: Replace all "5" with "9" using SUBSTITUTE
SUBSTITUTE(..., "5", "9") changes all 5's to 9's in the updated text.
Step 3: Combine functions correctly
Applying REPLACE first, then SUBSTITUTE on result is correct, matching =SUBSTITUTE(REPLACE(A1, 1, 2, "X5"), "5", "9").
Final Answer:
=SUBSTITUTE(REPLACE(A1, 1, 2, "X5"), "5", "9") -> Option A
Quick Check:
Chain REPLACE then SUBSTITUTE for combined changes [OK]
Hint: Nest REPLACE inside SUBSTITUTE to combine position and text changes [OK]
Common Mistakes:
Applying SUBSTITUTE before REPLACE causing wrong results
Concatenating results instead of nesting
Using SUBSTITUTE to replace by position
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.