Extract a category code (LEFT)
The problem
Problem statement
Your inventory sheet packs everything into one product code like PRD-1023: the first three letters are the category, the rest is the serial. Before you can build a category filter, the report needs a separate Category code column. Fill C2:C5 from the codes in A2:A5.
The prefix is always three characters — case 2 switches to a service code, so nothing about PRD-1023 may be hardcoded.
Problem data
Show the sheet as a table (selectable, copyable)
| A | C | |
|---|---|---|
| 1 | Product code | Category code |
| 2 | PRD-1023 | |
| 3 | PRD-2048 | |
| 4 | SRV-3011 | |
| 5 | ACC-5540 |
Notes
LEFT(text, n) returns the first n characters. The dash is character 4, so a 3-letter prefix stops right before it. If codes had variable prefix lengths, MID + SEARCH would be the more robust pattern.
How to approach
Your answer goes in C2:C5. On submit we re-run your formula against 3 different sets of input, so a hardcoded number will fail — the formula has to follow the cells.
- Target cells are C2:C5 — start in C2, then fill down
- The text to cut from is A2
- You only need the first 3 characters
LEFTtakes two arguments: the text and the character count
Official solutions
Show 2 solutions — try it yourself first
Approach 1: LEFT with a fixed length
=LEFT(A2, 3)
Returns the first 3 characters of A2 — the category prefix. Fill down through C5 to classify the whole list.
Approach 2: LEFT up to the dash (robust)
=LEFT(A2, SEARCH("-", A2) - 1)
SEARCH finds the dash position; subtracting 1 keeps everything before it. This still works if prefixes are ever 2 or 4 letters long.
Function guide
FAQ
How do I extract the first few characters of a cell?
Use =LEFT(A2, 3) to take the first 3 characters of A2. Replace 3 with however many characters your prefix needs.
What if prefixes have different lengths?
Stop at the delimiter instead: =LEFT(A2, SEARCH("-", A2) - 1) returns everything before the first dash, whatever its position.
Does LEFT change the original column?
No. It returns a new value in the formula cell; the source codes in column A stay untouched.