formulastreak

Text functions

LEFT and RIGHT functions in Google Sheets and Excel

LEFT returns the first characters of a text and RIGHT returns the last ones; you choose how many.

RIGHT returns the last characters of a text, such as the digits at the end of a code or the domain of an email.

Checked against Microsoft's and Google's documentation on · Example calculated on a live sheet

Syntax

LEFT(text, [num_chars])
RIGHT(text, [num_chars])

Arguments in [brackets] are optional. In Google Sheets: LEFT(string, [number_of_characters]) and RIGHT(string, [number_of_characters]).

Example

=LEFT(B2,4) reads: Take the first 4 characters of B2 (mara.okafor@example.com).

Workshop sign-ups · edit E2 and watch it recalculate
Click a cell (or use the arrow keys) to insert its address · Enter shows the resultE2 = mara
ABCDE
1NameEmailMember codeCityStart
2 mara okafor mara.okafor@example.comGB-2041Londonmara
3JONAS LINDjonas.lind@example.orgSE-1187Malmö
4priya ramanpriya.raman@example.netIN-3302Pune
5Tomás Ruiz tomas.ruiz@example.comES-0419Seville
6elif demirelif.demir@example.orgTR-2750Izmir
7 Kenji MORIkenji.mori@example.netJP-1093Osaka
8sofia rossisofia.rossi@example.comIT-4468Turin
9Leo Brandtleo.brandt@example.orgDE-3321Leipzig

E2 shows mara: the first 4 characters of mara.okafor@example.com.

How the spreadsheet calculates it

Takes the first 4 character(s) of B2.

  1. 1. LEFT: Takes the first 4 character(s) of B2.
    • text = `B2`: the cell to cut from
    • n = `4`: how many characters to take from the start

More LEFT and RIGHT examples

  • =LEFT(C2,2)The country part of a member code: GB.
  • =LEFT(B2,FIND("@",B2)-1)Everything before the @: mara.okafor.
  • =LEFT(B2,FIND(".",B2)-1)The first name from the email: mara.
  • =LEFT(TRIM(A2),1)The first letter of a name, after removing stray spaces.
  • =RIGHT(C2,LEN(C2)-FIND("-",C2))Everything after the dash: 2041, however long the number is.
  • =VALUE(RIGHT(C2,4))The last 4 digits as a number you can calculate with.
  • =RIGHT(B2,LEN(B2)-FIND("@",B2))The domain of an email: example.com.
  • =RIGHT(B2,3)The last three letters of an email: com, org or net.

Paste any of these into the formula explainer to see it step by step.

Tips

  • Combine with FIND or LEN when the pieces vary in length.
  • TRIM first: leading and trailing spaces count as characters.
  • Wrap the result in VALUE when you need a number.
  • For text between two characters, use MID with two FINDs.

What LEFT and RIGHT are used for

Splitting codes into parts (country prefix, number), taking usernames or domains from emails, initials from names, year or month from text dates, and the last digits of an account or phone number.

Arguments

LEFT

ArgumentRequiredWhat it is
textYesThe text or cell to cut from, such as B2.
num_charsNoHow many characters to take from the start. Left out, it's 1. More than the text's length returns the whole text.Watch out: It must be zero or more; a negative number, often a FIND result minus too much, gives #VALUE!.

RIGHT

ArgumentRequiredWhat it is
textYesThe text or cell to cut from, such as C2.
num_charsNoHow many characters to take from the end. Left out, it's 1. It must be zero or more.

Common mistakes

  • Forgetting that spaces and punctuation count as characters.

  • Using a fixed count on texts of different lengths: LEFT(B2,4) suits mara but cuts other names short. Let FIND work out the count, as in LEFT(B2,FIND(".",B2)-1).

  • Forgetting the -1 after FIND: the result then includes the character you searched for.

  • Expecting a number: RIGHT always returns text, even when it looks like digits.

  • Using FIND, which counts from the start, as RIGHT's count: the number of characters after the dash is LEN(C2)-FIND("-",C2).

  • Trailing spaces count: RIGHT of "Tomás Ruiz " returns spaces before letters. TRIM first.

In Google Sheets

Google Sheets has LEFT and RIGHT with the same arguments, written (string, [number_of_characters]); the count is optional in both apps.

Errors you may see with LEFT and RIGHT

  • #VALUE!: num_chars is negative, or comes from a FIND that didn't find its character (FIND's #VALUE! is passed on).

Questions

How do I get the text before a character?

Find the character and take one less: =LEFT(B2,FIND("@",B2)-1) is everything before the @. Excel 2024 and Microsoft 365 also have TEXTBEFORE, which Google Sheets doesn't.

How do I get the text after a character?

Count what's left after it: =RIGHT(B2,LEN(B2)-FIND("@",B2)) returns example.com. In Excel 2024 and Microsoft 365, TEXTAFTER does it directly.

How do I turn the result into a number?

LEFT and RIGHT always return text. Wrap the result in VALUE: VALUE(RIGHT(C2,4)) is the number 2041, which you can add and compare.

How do I remove the first or last few characters?

Keep everything except them: RIGHT(A2,LEN(A2)-3) drops the first 3 characters, LEFT(A2,LEN(A2)-1) drops the last one.

Practise LEFT and RIGHT on a live sheet

Lesson 23, Cut text: LEFT, RIGHT and MID (Unit 6, Text and dates), has 3 graded exercises, checked instantly, with steps and hints when you're stuck. Pro