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
- Excel 2016
- Excel 2019
- Excel 2021
- Excel 2024
- Microsoft 365
- Google Sheets
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).
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Name | Member code | City | Start | |
| 2 | mara okafor | mara.okafor@example.com | GB-2041 | London | mara |
| 3 | JONAS LIND | jonas.lind@example.org | SE-1187 | Malmö | |
| 4 | priya raman | priya.raman@example.net | IN-3302 | Pune | |
| 5 | Tomás Ruiz | tomas.ruiz@example.com | ES-0419 | Seville | |
| 6 | elif demir | elif.demir@example.org | TR-2750 | Izmir | |
| 7 | Kenji MORI | kenji.mori@example.net | JP-1093 | Osaka | |
| 8 | sofia rossi | sofia.rossi@example.com | IT-4468 | Turin | |
| 9 | Leo Brandt | leo.brandt@example.org | DE-3321 | Leipzig |
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. LEFT: Takes the first
4character(s) ofB2.text=`B2`: the cell to cut fromn=`4`: how many characters to take from the start
RIGHT example
=RIGHT(C2,4) reads: Take the last 4 characters of C2 (GB-2041).
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Name | Member code | City | Number | |
| 2 | mara okafor | mara.okafor@example.com | GB-2041 | London | 2041 |
| 3 | JONAS LIND | jonas.lind@example.org | SE-1187 | Malmö | |
| 4 | priya raman | priya.raman@example.net | IN-3302 | Pune | |
| 5 | Tomás Ruiz | tomas.ruiz@example.com | ES-0419 | Seville | |
| 6 | elif demir | elif.demir@example.org | TR-2750 | Izmir | |
| 7 | Kenji MORI | kenji.mori@example.net | JP-1093 | Osaka | |
| 8 | sofia rossi | sofia.rossi@example.com | IT-4468 | Turin | |
| 9 | Leo Brandt | leo.brandt@example.org | DE-3321 | Leipzig |
E2 shows 2041: the last 4 characters of GB-2041 (as text, not a number).
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
| Argument | Required | What it is |
|---|---|---|
| text | Yes | The text or cell to cut from, such as B2. |
| num_chars | No | How 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
| Argument | Required | What it is |
|---|---|---|
| text | Yes | The text or cell to cut from, such as C2. |
| num_chars | No | How 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
FINDwork out the count, as inLEFT(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.
Sources
Official documentation the facts on this page were checked against.