Text and cleaning · About 5 minutes
Take part of a text with LEFT, RIGHT and MID
Codes often pack several facts into one cell. In BLR, the first three letters are the city, the four digits are the design number, and the last letter is the size.
LEFT takes characters from the start and RIGHT takes them from the end. =LEFT( reads as "take the first 3 characters of A2". The number after the comma says how many.
MID takes characters from the middle. =MID( reads as "start at character 5 of A2 and take 4". Each dash counts as a character too.
Part of Plus
Free during our founding launch: sign in to unlock this lesson's exercises, the timed practice sets and the rest of Plus. The free lessons stay free, with no account needed.
What LEFT, RIGHT and MID does
LEFT, RIGHT and MID copy part of the text in a cell. LEFT takes characters from the start, RIGHT takes them from the end, and MID takes them from anywhere in between. A character is any letter, digit, space or symbol, so a dash counts as one.
They are useful when one cell holds several facts, like a staff ID that carries the joining year, or a product code that ends in a size. You pull out the piece you need into its own column, and the original stays as it was.
How to write LEFT, RIGHT and MID
=LEFT(
- text
- The cell to copy from, like A2.
- num_chars
- How many characters to take from the start. The square brackets mean it's optional: leave it out and LEFT takes just one.
=RIGHT(
- text
- The cell to copy from.
- num_chars
- How many characters to take from the end. It is optional too, and one is the default.
=MID(
- text
- The cell to copy from.
- start_num
- The position of the first character to take, counting the first character of the cell as 1.
- num_chars
- How many characters to take from that position. MID needs all three parts.
LEFT, RIGHT and MID worked example
Each staff ID holds the year the person joined. In C2, take the 4-digit year, then fill down to C5.
| A | B | C | |
|---|---|---|---|
| 1 | Name | Staff ID | Year |
| 2 | Maya | HR-2019-04 | 2019 |
| 3 | Omar | HR-2021-17 | 2021 |
| 4 | Lena | IT-2016-09 | 2016 |
| 5 | Jon | IT-2023-31 | 2023 |
=MID( B2, 4, 4)Start at character 4 of B2, just after the first dash, and take 4 characters: the first row shows 2019. Filled down, the column shows 2019, 2021, 2016 and 2023.Common LEFT, RIGHT and MID mistakes
The result is off by one character
Count every character, including dashes and spaces. In HR the year starts at character 4, because the dash is character 3.
The numbers it takes won't add up
LEFT, RIGHT and MID always give text, even when it looks like a number, and SUM skips text. Wrap the formula in VALUE to turn it into a real number.
It works on one row but not the next
A fixed count only works when every cell has the same layout. When the length changes from row to row, use FIND to locate a dash or a space and cut there.
LEFT, RIGHT or MID?
Use LEFT when the part you want starts the text, and RIGHT when it ends the text. Use MID for anything in the middle, or when you know where the part starts but not how far it is from the end.
All three work the same way in Excel and Google Sheets. When the break point moves from row to row, as in names of different lengths, pair them with FIND, which tells you where a character sits.
Questions people ask
What is the difference between LEFT, RIGHT and MID?
LEFT takes characters from the start, RIGHT from the end, and MID from any position you choose.
How do I get the first 3 characters of a cell?
Use =LEFT(.
Why does MID return the wrong characters?
The start position is off. Count every character from 1, dashes and spaces included.
Why can't I add up the numbers LEFT gives me?
LEFT, RIGHT and MID always return text. Wrap them in VALUE, like =VALUE(, to get a number.
Does MID work the same in Google Sheets?
Yes. LEFT, RIGHT and MID take the same parts there.
How do I remove the first 3 characters?
Keep the rest from the right: =RIGHT(. LEN counts the characters, so the formula works for any length.