LEFT, RIGHT Functions
The LEFT function returns the leftmost characters in a text string based on the number of characters you specify in one of its arguments. The RIGHT function returns the rightmost characters in a text string based on a number you specify.
Syntax
LEFT(text, [num_chars])
RIGHT(text,[num_chars])
Arguments
Argument
Description
Text
Required. This argument represents the text string with the characters you want to extract.
Num_chars
Optional. This is a number that specifies the number of characters you want to extract from the left (for the LEFT function) or right (for the RIGHT function).
Remarks
Example
In the example below, we use the LEFT and RIGHT functions to extract portions of text in different ways.
Formula explanations
=LEFT(A2)
This formula takes in cell A2 as the text argument and ignores the optional Num_chars argument. This returns the first character on the left of the string.
=RIGHT(A3)
This formula takes in cell A3 as the text argument and ignores the optional Num_chars argument. Hence the result it returns is the last character in the string (or first from the right).
=LEFT(A4,7)
This formula takes in cell A4 as the text argument and has 7 as the Num_chars argument. It returns “Arizona” which is 7 characters from the left of the string.
=RIGHT(A5,2)
This formula takes in cell A4 as the text argument and has 7 as the Num_chars argument. It returns “AR” which is 2 characters from the right of the string.
=LEFT(A6,FIND("-",A6)-1)
This formula takes in cell A6 as the text argument. We calculate the Num_chars argument by using the FIND function to find and return the position of the dash character (-) in the text.
We then subtract 1 from the result to return the number of characters in the text before the dash. Hence FIND("-",A6)-1 will return 10. The result is California. This formula will work for any piece of text separated by a dash for which you want to extract the left portion.
=RIGHT(A9,LEN(A9)-(FIND("-",A9)+1))
This formula takes in cell A9 as the text argument. We calculate the Num_chars argument by first using FIND to return the position of the dash character (-) in the text. We then add 1 to move to the position of the first character after the dash (on the right).
The LEN function is used to get the length of the string as we want to subtract the number of characters returned by FIND to give us the number of characters after the dash, which is 2 in this case.
This formula will work for any piece of text separated by a dash for which you want to extract the right portion, regardless of the number of characters after the dash.