The request

From Andrew Ramos, Marketing Manager
Your goal
In D2:D41, build the tracking code: the first 3 letters of the category in lowercase, a hyphen, then the product_id. In E2:E41, build the slug: the name in lowercase with every space replaced by a hyphen. In F2:F41, return "yes" when the name contains the keyword in I1 as a whole word, otherwise "no" (use IF, ISNUMBER and SEARCH).
- Fill
D2:F41with the right valuesnot done yet - With formulas, not typed numbersnot done yet
- Use
LOWERSUBSTITUTESEARCHISNUMBERnot done yet
Your sheet
| A | B | C | D | E | F | G | H | I | J | |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | product_id | name | category | code | slug | has_keyword | Keyword | oak | ||
| 2 | 161 | Cove Jute Duvet Cover | Textiles | |||||||
| 3 | 162 | Oakley Jute Knit Throw | Textiles | |||||||
| 4 | 163 | Pine Cotton Area Rug | Textiles | |||||||
| 5 | 164 | Cove Wool Lumbar Pillow | Textiles | |||||||
| 6 | 165 | Weston Cashmere-Blend Quilt | Textiles | |||||||
| 7 | 166 | Harbor Wool Knit Throw | Textiles | |||||||
| 8 | 167 | Elm Cashmere-Blend Area Rug | Textiles | |||||||
| 9 | 168 | Upland Percale Lumbar Pillow | Textiles | |||||||
| 10 | 169 | Spruce Wool Duvet Cover | Textiles | |||||||
| 11 | 170 | Rowan Cashmere-Blend Throw Blanket | Textiles | |||||||
| 12 | 171 | Driftwood Percale Area Rug | Textiles | |||||||
| 13 | 172 | Maple Wool Throw Pillow | Textiles | |||||||
| 14 | 173 | Bramble Percale Quilt | Textiles | |||||||
| 15 | 174 | Vale Cashmere-Blend Knit Throw | Textiles | |||||||
| 16 | 175 | Glen Cotton Runner Rug | Textiles | |||||||
| 17 | 176 | Fairhaven Cotton Throw Pillow | Textiles | |||||||
| 18 | 177 | Delancey Cashmere-Blend Duvet Cover | Textiles | |||||||
| 19 | 178 | Sutton Wool Knit Throw | Textiles | |||||||
| 20 | 179 | Delancey Jute Area Rug | Textiles | |||||||
| 21 | 180 | Hazel Linen Throw Pillow | Textiles | |||||||
| 22 | 181 | Cedar Marble Bud Vase | Decor | |||||||
| 23 | 182 | Nantucket Brass Wall Mirror | Decor | |||||||
| 24 | 183 | Glen Glass Canvas Print | Decor | |||||||
| 25 | 184 | Thatcher Oak Candle | Decor | |||||||
| 26 | 185 | Ridge Brass Bud Vase | Decor | |||||||
| 27 | 186 | Birch Brass Floor Mirror | Decor | |||||||
| 28 | 187 | Ashford Oak Canvas Print | Decor | |||||||
| 29 | 188 | Fern Oak Candle Holder Set | Decor | |||||||
| 30 | 189 | Northfield Brass Bud Vase | Decor | |||||||
| 31 | 190 | Elm Brass Floor Mirror | Decor | |||||||
| 32 | 191 | Hazel Ceramic Canvas Print | Decor | |||||||
| 33 | 192 | Thatcher Marble Candle Holder Set | Decor | |||||||
| 34 | 193 | Delancey Brass Vase | Decor | |||||||
| 35 | 194 | Chester Brass Wall Mirror | Decor | |||||||
| 36 | 195 | Fairhaven Soy Wax Framed Print | Decor | |||||||
| 37 | 196 | Pine Glass Candle Holder Set | Decor | |||||||
| 38 | 197 | Ridge Soy Wax Vase | Decor | |||||||
| 39 | 198 | Harbor Oak Floor Mirror | Decor | |||||||
| 40 | 199 | Oakley Brass Framed Print | Decor | |||||||
| 41 | 200 | Cedar Ceramic Candle | Decor | |||||||
| 42 | ||||||||||
| 43 |
Loading the editor…
Reference solution
Mote checks your result
Press Check. Each right cell becomes a firefly in your lantern.
What Andrew gets, and why
The lesson
Andrew’s ticket is three columns, each built from text that is already in the sheet. The trick in all three is not a new function but functions inside functions. Excel evaluates the innermost one first and hands its answer outward, which lets you do in one cell what would otherwise take two or three helper columns.
A code from part of a column
The category in C2 is Textiles. Andrew wants tex-161:
D2 =LOWER(LEFT(C2,3))&"-"&A2
Read it from the inside: LEFT(C2,3) is Tex, LOWER turns it into tex, then & adds a
hyphen and the product_id. Standardising case is the point of LOWER here: if one export says
TEXTILES and another Textiles, both still give tex, and codes that should match do match.
Decor products get dec-181 and so on.
A slug with SUBSTITUTE
SUBSTITUTE(text, old, new) replaces every occurrence of old with new:
E2 =LOWER(SUBSTITUTE(B2," ","-"))
Cove Jute Duvet Cover becomes cove-jute-duvet-cover. Row 6, Weston Cashmere-Blend Quilt,
already has a hyphen; it stays, and the slug is weston-cashmere-blend-quilt. SUBSTITUTE takes an optional fourth argument to replace only
one occurrence: SUBSTITUTE(B2," ","-",1) changes the first space only.
The same nesting cleans free text such as review comments. =TRIM(LOWER(review)) lowercases the
text, removes spaces at both ends and collapses runs of spaces inside it to one, and wrapping that
in SUBSTITUTE(…,"!!","!") fixes a habit Excel has no function for. Chapter 5 is all about that
kind of cleaning.
Does the name contain a word?
SEARCH(find, within) returns the position where find starts, or #VALUE! when it isn’t there.
ISNUMBER turns that into TRUE or FALSE, and IF into the words you want:
=IF(ISNUMBER(SEARCH($I$1,B2)),"yes","no")
It works on row 25, Thatcher Oak Candle. Now look at row 3: B3 is Oakley Jute Knit Throw,
and oak is inside Oakley, so the formula says “yes” for a throw made of jute. The same happens in row 40, Oakley Brass Framed Print.
The fix is to search for the word with a space on each side, inside the name with a space added at each end, so a word at the start or the end of the name still has spaces around it:
F2 =IF(ISNUMBER(SEARCH(" "&$I$1&" "," "&B2&" ")),"yes","no")
Now " oak " is found in " Thatcher Oak Candle " but not in " Oakley Jute Knit Throw ".
Filled down, 4 of the 40 products get “yes”. Change I1 to brass and the column follows: 8
products.
FIND or SEARCH
FIND |
SEARCH |
|
|---|---|---|
| Upper and lower case | must match: FIND("oak","Oak") is #VALUE! |
ignored |
Wildcards * and ? |
no | yes |
The names say Oak and the keyword cell says oak, so SEARCH is the right one. Use FIND when
case matters, for example to tell the code ABC from abc.
Common mistakes
- No ISNUMBER.
=IF(SEARCH(…),"yes","no")returns#VALUE!on every row without the word, because the error flows throughIF. - Partial words.
oakmatchesOakley, andelmwould matchHelmsley. Pad with spaces when you mean a whole word. - LOWER on the wrong piece.
=LEFT(LOWER(C2),3)works too, but=LOWER(LEFT(C2),3)has the 3 in the wrong function: count the brackets. - Typing the keyword into the formula. Keep it in
I1and lock it, so the next campaign is one cell away.
Lantern lit!
Practised: nested functionslowersubstitutesearchisnumberif
- Solved
- No hints
- First run
