The LEFT function
LEFT takes characters from the start of some text: the depot letters at the front of a stock code, the area part of a postcode, or someone's initial.
You tell it how many characters you want and it counts from the left. When the piece you need varies in length, pair it with FIND to work out the count.
=LEFT(text, [num_chars])
Arguments
- text
- The text (or cell) to take characters from.
- num_charsoptional
- How many characters to take from the start. Leave it out to take just one.
Try it
=LEFT(A2,3) in B2. The first three characters of LDN-0421-BLU are LDN, the depot code.
B2
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Stock code | Depot | ||
| 2 | LDN-0421-BLU | LDN | ||
| 3 | MAN-1187-RED | |||
| 4 | BRS-0090-GRN | |||
| 5 | EDIN-2304-BLK | |||
| 6 | ||||
| 7 |
Edit the formula in B2, or change the data, and press Enter.
More examples
| Formula | Result | What it does |
|---|---|---|
| =LEFT(A3,8) | MAN-1187 | Eight characters: the depot, the dash and the item number. |
| =LEFT(A4) | B | With no count, LEFT returns just the first character. |
| =LEFT(A5,FIND("-",A5)-1) | EDIN | FIND locates the first dash, so this works for depot codes of any length. |
Tips
- Use
FIND("-",A2)-1(or a space," ") as the count to take everything before a separator, whatever its length. - Asking for more characters than the text has is fine: LEFT simply returns the whole text.
- In Excel 365,
TEXTBEFOREdoes the same job as LEFT with FIND and is easier to read. Google Sheets doesn't have it, so LEFT with FIND is the version that works everywhere.
Common mistakes
- LEFT on a date gives a strange number like 45.A date is stored as a serial number, so LEFT sees its digits. Use
TEXT(A2,"dd/mm/yyyy")first, or YEAR, MONTH and DAY. - The digits you pulled out won't add up.LEFT always returns text. Wrap it in VALUE, or add zero (
=LEFT(A2,4)+0), to get a real number. - Codes with leading spaces come back looking empty or short.Clean the text first:
=LEFT(TRIM(A2),3).
Practise LEFT with instant feedback
Type real formulas into a working spreadsheet and get told straight away whether they work.