
What are LEFT, RIGHT and MID in Excel?
LEFT, RIGHT, and MID extract characters from a text value. LEFT starts at the beginning, RIGHT starts at the end, and MID starts at a position you specify. They are useful for cleaning product codes, invoice references, imported contact lists, and inconsistent identifiers.
Syntax of LEFT, RIGHT and MID
=LEFT(text,[num_chars])
=RIGHT(text,[num_chars])
=MID(text,start_num,num_chars)
text is the cell or text to extract from. The optional num_chars for LEFT and RIGHT defaults to 1. MID requires a start position and a number of characters. Excel counts positions beginning with 1.
Example 1: LEFT extracts the starting letters
If A2 contains INV-2026-1045, enter:
=LEFT(A2,3)
Result: INV. This extracts the three-character invoice prefix without changing the original entry.
Example 2: RIGHT extracts a trailing code
Using the same invoice reference:
=RIGHT(A2,4)
Result: 1045. This result is text even if it looks numeric. Use VALUE only if your next calculation truly requires a number; converting can remove leading zeros.
Example 3: MID extracts characters from the middle
=MID(A2,5,4)
Result: 2026. In INV-2026-1045, the fifth character starts the year and MID takes the next four.
Example 4: Extract a code before a hyphen
For values such as HR-0048, use FIND to locate a variable-length prefix:
=LEFT(A2,FIND("-",A2)-1)
Result: HR. FIND returns the hyphen’s position and LEFT extracts everything before it. If the hyphen is absent, FIND produces #VALUE!, so inspect input consistency or handle the error thoughtfully.
Example 5: Extract a domain from an email
If B2 contains asha@example.com:
=RIGHT(B2,LEN(B2)-FIND("@",B2))
Result: example.com. LEN counts all characters and FIND locates the @ sign, so RIGHT takes exactly the characters after it.
Example 6: Combine MID with FIND
If A2 is Order-[East]-1045, and the region is enclosed in square brackets:
=MID(A2,FIND("[",A2)+1,FIND("]",A2)-FIND("[",A2)-1)
Result: East. This adapts if the region label changes length, provided the brackets are present.
LEFT/RIGHT/MID vs TEXTSPLIT
Use LEFT, RIGHT or MID when positions or identifiable markers matter. TEXTSPLIT is convenient when a delimiter divides data into several pieces and your Excel version supports dynamic array functions.
Common mistakes
- Wrong starting position: MID starts at 1, not 0.
- Text rather than numbers: extracted digits are typically text; avoid discarding significant leading zeros.
- #VALUE!: check that MID uses a valid positive start position and nonnegative character count, and that FIND locates its marker.
- Unexpected spaces: use TRIM when imported data contains extra ordinary spaces.
- Fixed-length assumptions: use FIND or SEARCH for variable-length codes instead of always taking the first three characters.
Frequently asked questions
Can LEFT extract numbers?
It can extract digits, but returns a text string. VALUE can convert appropriate numeric strings to numbers.
Can MID count from the end?
MID uses a start position from the left. Combine LEN and RIGHT when counting backwards is easier.
Do these functions change the original value?
No. They return extracted text in the formula cell; the source value is unchanged.
Practice exercise
Create ten invoice IDs in the format INV-2026-1001. Extract the prefix, year, and final four digits into separate columns. Then try one value with an unexpected delimiter and see how to validate it.
Related Excel tutorials
Explore our Excel Functions module for more formula tutorials and real-world spreadsheet examples.
Official reference
For syntax and product-version details, consult Microsoft Excel Support.
