These three functions cut a piece of text out of a cell.
LEFT: characters from the start
=LEFT(A2, 3) returns the first 3 characters. For LAP-2045 it gives LAP.
RIGHT: characters from the end
=RIGHT(A2, 4) returns the last 4 characters. For LAP-2045 it gives 2045.
MID: characters from the middle
=MID(A2, start, count)
=MID(A2, 5, 2) starts at character 5 and takes 2 characters. For LAP-2045 it gives 20.
Combine with FIND and LEN
- Text before a dash:
=LEFT(A2, FIND("-", A2)-1)
- Text after a dash:
=RIGHT(A2, LEN(A2)-FIND("-", A2))
Results are text
These functions return text, even for digits. To use the result as a number, wrap it in VALUE, or multiply by 1.
In Microsoft 365, TEXTBEFORE and TEXTAFTER do the same job with less typing.
Worked example
A2 holds "INV-2026-045". =LEFT(A2,3) returns INV. =RIGHT(A2,3) returns 045. =MID(A2,5,4) returns 2026: start at character 5 and take 4.
Common mistakes
- Counting the start position from 0. It starts at 1.
- Expecting numbers back. These return text, so wrap in VALUE if needed.
- Hard-coding lengths when the text varies. Combine with FIND.
Frequently asked questions
How do I take text before a character?
=LEFT(A2,FIND("-",A2)-1).
How do I get the last word?
=TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",50)),50)).
What if the length is longer than the text?
You just get the whole text, with no error.
Practice this online, free
Reading is only half of learning Excel. Cellgrids is a free place for online Excel practice: solve Excel formula exercises in a live spreadsheet, prepare for Excel interview questions, and work through business case studies built for data analytics and business analytics roles.
Practice these formulas: LEFT, RIGHT, MID, LEN.
Start Excel practice → Case studies