Excel functions · Text

LEFT, RIGHT and MID functions in Excel

LEFT, RIGHT and MID take characters out of a text string: LEFT from the start, RIGHT from the end, and MID from any position you give. They're how you pull a prefix, a year or a code out of IDs like INV-2026-0042.

Last reviewed

Syntax

=LEFT(text, [num_chars])
=RIGHT(text, [num_chars])
=MID(text, start_num, num_chars)
textrequired
The text to take characters from.
num_charsrequired
How many characters to return. Optional in LEFT and RIGHT (defaults to 1), required in MID.
start_numrequired
MID only: the position of the first character to take, counting from 1.
  • The result is always text, so "0042" keeps its zeros. Use VALUE to turn it into a number.
  • When the part you want varies in length, find the delimiter with FIND or SEARCH: LEFT(A3, FIND("-", A3)-1).
  • Asking for more characters than exist just returns the whole remaining text.

Which versions have LEFT, RIGHT and MID

Every current Excel version: Microsoft 365, Excel for the web, Excel 2024, 2021, 2019 and 2016, on Windows and Mac.

LEFT, RIGHT and MID availability by Excel version
VersionHas them
Microsoft 365 (Windows and Mac)Yes
Excel for the webYes
Excel 2024Yes
Excel 2021Yes
Excel 2019Yes
Excel 2016Yes

Google Sheets

Google Sheets has LEFT, RIGHT and MID with the same arguments.

Examples

The examples use this sample sheet.

Codes (A1:A3)
RowA
1Code
2INV-2026-0042
3US-NY-10001
  1. 1.The first three characters

    =LEFT(A2, 3)

    Result: INV

    LEFT takes characters from the start.

  2. 2.The last four characters

    =RIGHT(A2, 4)

    Result: 0042

    The result is text, so the leading zeros stay.

  3. 3.Characters from the middle

    =MID(A2, 5, 4)

    Result: 2026

    Start at the 5th character (after "INV-") and take 4.

Common errors and fixes

LEFT, RIGHT and MID errors, causes and fixes
ErrorWhy it happensFix
#VALUE!num_chars is negative, or MID's start_num is less than 1. Often a FIND that found nothing.Check the FIND or SEARCH part, or wrap it in IFERROR.
Numbers that won't add upThe extracted digits are text.Wrap the formula in VALUE: =VALUE(MID(A2, 5, 4)) returns the number 2026.

Do it with GPTExcel

Skip writing LEFT, RIGHT and MID by hand

Upload your Excel or CSV file to Chat and ask in plain English. GPTExcel writes the formula for your file and your version of Excel or Google Sheets.

your-file.xlsx

Pull the year and the invoice number out of codes like INV-2026-0042 into two columns.

Done. I used these functions on your sheet and checked the results against your data.

your-file-updated.xlsxYour original stays unchanged
  • Written for your platform and version
  • Checked against your actual data
  • Newest functions looked up in official docs
Try it free Formula Generator

Free plan, no credit card.

LEFT, RIGHT and MID questions

How do I extract text before a dash in Excel?
Find the dash and take everything before it: =LEFT(A3, FIND("-", A3)-1) returns "US" from US-NY-10001. In Microsoft 365, TEXTBEFORE(A3, "-") does the same.
Why doesn't my LEFT result add up as a number?
LEFT, RIGHT and MID always return text. Wrap the formula in VALUE, or put -- in front, to make it a number.

Skip the formula hunt

Upload a spreadsheet and ask in plain English. Free plan, no credit card.

Start free