cellio

LEFT, RIGHT and MID in Excel: Extract Part of a Cell

Use LEFT, RIGHT and MID with LEN and FIND to pull out codes, first names, area codes and file extensions from text. Clear examples for each function.

By Ayoub Farid · · 1 min read

When the data you need is stuck inside a longer cell ("INV-2026-0042", "Sam Lee", "report.xlsx"), these three functions cut it out.

The basics

=LEFT(text, num_chars)
=RIGHT(text, num_chars)
=MID(text, start_num, num_chars)

With "INV-2026-0042" in A2:

FormulaResult
=LEFT(A2,3)INV
=RIGHT(A2,4)0042
=MID(A2,5,4)2026

When lengths vary: add FIND and LEN

Fixed character counts only work for fixed-format codes. For names, find the space:

First name:

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

Last name:

=RIGHT(A2,LEN(A2)-FIND(" ",A2))
  • FIND returns the position of the space.
  • LEN returns the total length.

File extension

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

(Assumes one dot. For "my.report.xlsx", use TEXTAFTER below.)

The results are text

=RIGHT(A2,4) returns "0042" as text. To use it as a number: =VALUE(RIGHT(A2,4)) or =--RIGHT(A2,4).

The modern way: TEXTBEFORE and TEXTAFTER

In Microsoft 365 and Google Sheets:

=TEXTBEFORE(A2," ")     first name
=TEXTAFTER(A2," ")      last name
=TEXTAFTER(A2,".",-1)   text after the last dot

Much easier to read. For splitting into several columns at once, see split text.

Frequently asked questions

How do I extract the first word in Excel?

=LEFT(A2,FIND(" ",A2)-1), or =TEXTBEFORE(A2," ") in Microsoft 365.

How do I get the last 4 characters of a cell?

=RIGHT(A2,4).

Why does FIND return #VALUE!?

The character you're searching for isn't in the cell. Wrap in IFERROR or check the data.

FIND is case-sensitive and doesn't allow wildcards; SEARCH ignores case and allows them.

Keep reading