LEFT, RIGHT and MID in Excel
LEFT, RIGHT and MID pull characters out of a text string. LEFT takes characters from the start, RIGHT takes them from the end, and MID takes a run of characters from a position you choose. Paired with FIND and LEN, they parse structured codes like tickers, account numbers, and SKUs into clean component fields you can group, sort, and look up against.
Syntax and how each one works
The signatures are =LEFT(text, [num_chars]), =RIGHT(text, [num_chars]) and =MID(text, start_num, num_chars). LEFT and RIGHT default to one character if you omit the count. MID always needs a start position and a length.
Positions are one based, so the first character is position 1. LEFT counts from the left edge, RIGHT counts from the right edge, and MID begins at start_num and takes num_chars characters moving right. All three return text, even when the characters happen to be digits.
Worked example: parse an account code
An account code in A2 reads AAPL-1234-US. You want the ticker before the first dash, the four digit number in the middle, and the country at the end. The code uses a fixed layout where the ticker is four characters, then a dash, then four digits, then a dash, then two characters.
- Extract the ticker with
=LEFT(A2, 4), which returns AAPL. - Extract the number with
=MID(A2, 6, 4), which starts at position 6 and takes 4 characters to return 1234. - Extract the country with
=RIGHT(A2, 2), which returns US. - To avoid hardcoding the ticker length, find the first dash with
=LEFT(A2, FIND("-", A2)-1), which returns everything before it.
| Part | Formula | Result |
|---|---|---|
| Ticker | =LEFT(A2, 4) | AAPL |
| Number | =MID(A2, 6, 4) | 1234 |
| Country | =RIGHT(A2, 2) | US |
For A2 equal to AAPL-1234-US, MID starts at position 6, just after the first dash, and takes 4 characters.
How analysts use LEFT, RIGHT and MID
These functions turn coded identifiers into usable dimensions for grouping and lookups.
- Split a ticker with exchange suffix, like RIO.L, into the symbol and the exchange.
- Pull a department prefix from a GL account string to roll up costs.
- Combine with FIND to handle variable length parts instead of fixed positions.
- Use LEN with RIGHT to grab everything after a known prefix when the tail length varies.
Common pitfalls
These functions return text, so an extracted number is a text string until you coerce it. Wrap it in VALUE, as in =VALUE(MID(A2, 6, 4)), or add zero, when you need to do math or match against numeric data.
Fixed positions are brittle. If the ticker length varies, =LEFT(A2, 4) cuts the wrong place, so use FIND to locate the delimiter dynamically. A common robust pattern for the middle segment is =MID(A2, FIND("-", A2)+1, FIND("-", A2, FIND("-", A2)+1) - FIND("-", A2) - 1), which finds the first dash, then the second dash, and takes everything between them regardless of length.
Prepare to Share
Prepare to Share cleans a workbook before you send parsed code tables out, so stray helper columns do not travel with the file.
Get ModelMint See how it worksFAQ
How do I extract text between two characters in Excel?
Use MID with FIND to locate the delimiters. Find the first marker, start just after it, and set the length to the gap to the next marker, like =MID(A2, FIND("-", A2)+1, FIND("-", A2, FIND("-", A2)+1) - FIND("-", A2) - 1).
Why does MID return text instead of a number?
LEFT, RIGHT and MID always return text, even for digits. Convert the result with VALUE, as in =VALUE(MID(A2, 6, 4)), or add zero so Excel treats it as a number for calculations and lookups.
What is the difference between LEFT, RIGHT and MID?
LEFT takes characters from the start of a string, RIGHT takes them from the end, and MID takes a run of characters from a position you specify. MID is the most flexible because you control both the start and the length.