Templates, guides & honest tool reviews for small business

Sunday, November 29, 2026

LEFT, RIGHT and MID Functions in Excel: Extract Text with Examples

LEFT, RIGHT and MID functions in Excel to extract text
Illustration: LEFT, RIGHT and MID functions in Excel

The LEFT, RIGHT and MID functions in Excel pull a piece of text out of a cell: the first characters, the last characters or a slice from the middle. They are the quickest way to split codes, phone numbers and names without retyping anything. This guide explains each function with made-up data and shows how to combine them with FIND and LEN when the text has no fixed length.

LEFT: get the first characters

=LEFT(text, [num_chars])

If A2 holds the code INV-2026-045, then:

=LEFT(A2, 3)

returns INV. If you leave out the second argument, Excel returns one character.

RIGHT: get the last characters

=RIGHT(text, [num_chars])

=RIGHT(A2, 3)

returns 045, the last three characters of the same code.

MID function in Excel to extract the year from an invoice code
Made-up invoice code (illustration).

MID: get characters from the middle

=MID(text, start_num, num_chars)

MID needs a starting position and a length. To get the year 2026 from INV-2026-045, start at character 5 and take 4:

=MID(A2, 5, 4)

Find the position with FIND

When the text length changes, count characters with FIND instead of typing a number. FIND returns the position of a character inside the text:

=FIND("-", A2)

For INV-2026-045 this returns 4, the place of the first hyphen. FIND is case sensitive. SEARCH does the same job without case sensitivity and allows wildcards.

LEFT and FIND in Excel to get the first name from a full name
Take text before the space (illustration).

Get the first name from a full name

Say A2 holds Sara Ahmed. Take everything before the space:

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

The result is Sara. We subtract 1 so the space itself is not included.

RIGHT, LEN and FIND in Excel to get the last name
Take text after the space (illustration).

Get the last name from a full name

Take everything after the space. Use LEN for the total length:

=RIGHT(A2, LEN(A2) - FIND(" ", A2))

The result is Ahmed. This works for names with one space. For names with several parts, see the TEXTSPLIT note below.

VALUE function in Excel to convert extracted text to a number
Extracted text needs VALUE for math (illustration).

Get text between two characters

To pull the middle part of INV-2026-045 when the length can vary, find both hyphens:

=MID(A2, FIND("-", A2) + 1, FIND("-", A2, FIND("-", A2) + 1) - FIND("-", A2) - 1)

The third argument of FIND says where to start searching, so the second FIND skips the first hyphen. The formula is long. If you have a recent Excel, TEXTBEFORE and TEXTAFTER are easier, but they are not in older versions.

Turn the result into a number

LEFT, RIGHT and MID always return text, even when the characters are digits. To use the result in math, wrap it in VALUE or add zero:

=VALUE(RIGHT(A2, 3))

Clean the text first

Extra spaces break these formulas. Wrap the cell in TRIM before you cut it:

=LEFT(TRIM(A2), 3)

If a split is only part of a bigger task, see our guide to the SPLIT function in Google Sheets and to TEXTJOIN in Excel for joining text back together.

Common mistakes

  • Number as text. The result of MID looks like a number but will not add up until you use VALUE.
  • #VALUE! error. FIND did not locate the character, or the start number is below 1. Check the spelling of the character.
  • Off by one. Forgetting the minus 1 or plus 1 keeps a space or a hyphen in the result.
  • Leading zeros lost. Code 007 stored as the number 7 cannot be cut as 007. Keep such codes as text.

Questions and answers

What is the difference between MID and LEFT?

LEFT always starts from the first character. MID starts at any position you choose.

Can I use these functions in Google Sheets?

Yes. LEFT, RIGHT, MID, FIND and LEN work the same way there.

How do I get everything except the last character?

Use =LEFT(A2, LEN(A2) - 1).

Is there a way to split without formulas?

Yes. The Text to Columns tool on the Data tab splits a column by a delimiter such as a space, comma or hyphen.

Summary

Use LEFT and RIGHT for fixed ends, MID for a slice, and combine them with FIND and LEN when the length changes. Clean the text with TRIM first and convert with VALUE when you need numbers.

العربية