Excel String Functions: LEFT, RIGHT, MID, LEN and FIND

In this guide, you’ll see how to use the Excel string functions to retrieve specific characters from a string in Excel.

Specifically, you’ll observe how to apply the following Excel string functions using practical examples:

Excel String Functions UsedDescription of Operation
LEFTGet characters from the left side of a string
RIGHTGet characters from the right side of a string
MIDGet characters from the middle of a string
LEFT, FINDGet all characters before a symbol
LEFT, FINDGet all characters before a space
RIGHT, LEN, FINDGet all characters after a symbol
MID, FINDGet all characters between two symbols

Excel String Functions

To start, suppose that you stored different strings in Excel that contain a mixture of:

  • Letters
  • Digits
  • Symbols
  • Spaces

The ultimate goal is to isolate/retrieve only the digits within those strings.

Retrieve a specific number of characters from the left side of a string

In the example below, you’ll see 3 strings. Your goal is to retrieve only the 5 digits from the left-side:

(1) First, type/paste the table below into Excel, within the range of cells A1 to B4:

IdentifierResult
55555-End 
77777-End 
99999-End 

Since the goal is to retrieve the first 5 digits from the left, you’ll need to use the LEFT formula, which has the following structure:

=LEFT(Cell where the string is located, Number of characters needed FROM THE LEFT)

(2) Next, type the following formula in cell B2:

=LEFT(A2,5)

(3) Finally, drag the LEFT formula from cell B2 to B4 in order to get the results across your 3 records.

This is how your table would look like in Excel after applying the LEFT formula:

IdentifierResult
55555-End55555
77777-End77777
99999-End99999

Retrieve a specific number of characters from the right side of a string

To retrieve the 5 digits from the right-side of the strings:

(1) Type/paste the following table into cells A1 to B4:

IdentifierResult
ID-55555 
ID-77777 
ID-99999 

Here, use the RIGHT formula that has the following structure:

=RIGHT(Cell where the string is located, Number of characters needed FROM THE RIGHT)

(2) Then, type the following formula in cell B2:

=RIGHT(A2,5)

(3) Finally, drag your RIGHT formula from cell B2 to B4.

This is how the table would look like after applying the RIGHT formula:

IdentifierResult
ID-5555555555
ID-7777777777
ID-9999999999

Get a specific number of characters from the middle of a string

To retrieve the 5 digits from the middle of the strings:

(1) Type/paste the following table into cells A1 to B4:

IdentifierResult
ID-55555-End 
ID-77777-End 
ID-99999-End 

Here, use the MID formula with the following structure:

=MID(Cell of string, Start position of first character needed, Number of characters needed)

(2) Now type the following formula in cell B2:

=MID(A2,4,5)

(3) Finally, drag the MID formula from cell B2 to B4.

This is how the table would look like:

IdentifierResult
ID-55555-End55555
ID-77777-End77777
ID-99999-End99999

Gel all characters before a symbol (for varying-length strings)

To retrieve all the desired digits before a symbol (e.g., the hyphen symbol “-“) for varying-length strings:

(1) First, type/paste the following table into cells A1 to B4:

IdentifierResult
111-IDAA 
2222222-IDB 
33-IDCCC 

Here, you’ll need to use the FIND function to find your symbol:

=FIND(the symbol in quotations that you'd like to find, the cell of the string)

(2) Then, type the following formula in cell B2:

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

Note that the “-1” at the end of the formula simply drops the hyphen symbol from the final results.

(3) As before, drag your formula from cell B2 to B4 to see the complete results:

IdentifierResult
111-IDAA111
2222222-IDB2222222
33-IDCCC33

Gel all characters before a space (for varying-length strings)

To get all the digits before a space for varying-length strings:

(1) To start, type/paste the following table into cells A1 to B4:

IdentifierResult
111 IDAA 
2222222 IDB 
33 IDCCC 

(2) Then, type the following formula in cell B2 (here, simply leave an empty space within the double quotes):

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

(3) Finally, drag the formula from cell B2 to B4:

IdentifierResult
111 IDAA111
2222222 IDB2222222
33 IDCCC33

Obtain all characters after a symbol (for varying-length strings)

To get all the digits after the hyphen symbol (“-“) for varying-length strings:

(1) First, type/paste the following table into cells A1 to B4:

IdentifierResult
IDAA-111 
IDB-2222222 
IDCCC-33 

(2) Secondly, type the following formula in cell B2:

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

(3) Finally, drag your formula from cell B2 to B4:

IdentifierResult
IDAA-111111
IDB-22222222222222
IDCCC-3333

Obtain all characters between two symbols (for varying-length strings)

To retrieve only the digits between the two hyphen symbols for varying-length strings:

(1) First, type/paste the following table into cells A1 to B4:

IdentifierResult
IDAA-111-AA 
IDB-2222222-B 
IDCCC-33-CCC 

(2) Then, type the following formula in cell B2:

=MID(A2,FIND("-",A2)+1,FIND("-",A2,FIND("-",A2)+1)-FIND("-",A2)-1)

(3) And finally, drag your formula from cell B2 to B4:

IdentifierResult
IDAA-111-AA111
IDB-2222222-B2222222
IDCCC-33-CCC33

Leave a Comment