Excel Guide

How to Use LEFT, RIGHT and MID in Excel: Pull Text Out of a Code Without Retyping It

Short answer: =LEFT(text, num_chars) takes characters from the start, =RIGHT(text, num_chars) takes them from the end, and =MID(text, start_num, num_chars) takes them from a position you choose in the middle. Excel has no single SUBSTRING function — these three text functions do that job between them. They are the fix for product codes, staff IDs and imported lists where the piece you need is buried inside a longer string. Practise it: LEFT, RIGHT and MID — 10 Excel practice problems.

Take one code in A2: SG-2026-4021. The country prefix, the year and the serial number are all in there, and each function pulls out one piece:

=LEFT(A2, 2)  → SG
=MID(A2, 4, 4)  → 2026
=RIGHT(A2, 4)  → 4021

LEFT: characters from the start

LEFT returns a set number of characters from the beginning of a text string. Its syntax is =LEFT(text, [num_chars]), and the count is optional — leave it out and LEFT returns just the first character.

=LEFT("SG-2026-4021", 2)  → SG
=LEFT("SG-2026-4021")  → S

Use it for the fixed-width piece at the front: a country prefix, a department code, the first two letters of a customer ID. Counting includes every character — letters, digits, spaces and hyphens all count as one.

RIGHT: characters from the end

RIGHT is the mirror image: same two arguments, counted from the other end.

=RIGHT("SG-2026-4021", 4)  → 4021

Use it for the piece at the back: a serial number, a file extension, the last four digits of a reference. One thing to watch: what RIGHT pulls out arrives as text, even when it looks like a number. 4021 extracted this way is left-aligned in its cell and will not feed a SUM until you convert it — wrap it in VALUE() if you need to calculate with it.

MID: characters from the middle

MID is the flexible one. It takes three arguments, and all three are required: the text, the position to start at, and how many characters to take. Positions count from the left, and the first character is position 1.

=MID("SG-2026-4021", 4, 4)  → 2026

Count it out: S is 1, G is 2, the hyphen is 3, so position 4 is the 2 of 2026 — four characters from there gives the whole year. MID is the function to reach for whenever the piece you need is neither at the start nor at the end: a year inside a code, a middle name, a batch number between two hyphens.

When the length varies: let FIND do the counting

Fixed counts only work when every code is the same shape. Real lists are not. When the piece you need ends at a space, a comma or a hyphen, use FIND to locate that character and let LEFT or MID cut there instead of hard-coding a number. FIND returns the position of a character inside a string, and it is case-sensitive (SEARCH is the case-insensitive version).

To pull a first name out of a full name in A2:

=LEFT(A2, FIND(" ", A2)-1)

FIND locates the space, minus one backs up to the last letter of the first name, and LEFT takes everything up to there. The same pattern works for the text after a delimiter — measure with FIND, then cut with MID.

Three mistakes to avoid

Practise it

PractiseSkills' own diagnostic flags text functions as a common weak spot — its sample result shows Text functions at 47, the lowest of the nine skill areas, with the gap described as "cleaning messy imported data — TRIM, LEFT/MID and SUBSTITUTE." The site's practice modules cover exactly this: TRIM and CLEAN, LEFT / RIGHT / MID, and FIND and SUBSTITUTE, with 10 exercises each. Take the free diagnostic — one of its nine tasks covers text and data cleaning — then practise the LEFT, RIGHT and MID module from the homepage at practiseskills.com.

Try it yourself

Practice LEFT, RIGHT and MID with real interactive exercises and instant feedback.

Start practicing LEFT, RIGHT and MID →