## Summary

To extract the first name from a full name in "Last, First" format, you can use the TEXTBEFORE function. In the worksheet shown, the formula in cell D5 is:

=TEXTBEFORE(B5,",")

As the formula is copied down, it returns the last name from each name listed in column B.

Note: As of this writing, the TEXTBEFORE function is only available in Excel 365. See below for an alternative formula that will work in older versions of Excel

## Generic formula

=TEXTBEFORE(name,",")

## Explanation

In this example, the goal is to extract the last name from a list of names in "Last, First" format as seen in column B. In the current version of Excel, the easiest solution is to use the TEXTBEFORE function. In older versions of Excel, it can be solved with a more complex formula based on the LEFT and FIND functions. Both approaches are explained below.

### Modern solution

In the current version of Excel, the TEXTBEFORE function is the best way to solve this problem. TEXTBEFORE extracts text that occurs before a given delimiter. In its simplest form, TEXTBEFORE only requires two arguments, text and delimiter:

=TEXTBEFORE(text,delimiter)

In the worksheet shown, the formula we are using to return the last name looks like this:

=TEXTBEFORE(B5,",")
• text - B5, the name in column B
• delimiter - "," (a comma)

Note that the comma needs to be enclosed in double quotes (",") and there is no need to add a space after the comma. In this configuration, the TEXTBEFORE function simply returns all text that occurs before the comma. TEXTBEFORE has many other options that you can read more about here.

### Legacy solution

In older versions of Excel that do not provide the TEXTBEFORE function, you can solve this problem with a more complex formula based on the RIGHT, LEN, and FIND functions:

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

At a high level, the LEFT function extracts text starting at the left side of a text string. LEFT takes two arguments, text and num_chars, which indicates how many characters to extract:

=LEFT(text,num_chars)

For example, if we use "apple" for text and 3 for num_chars, we get "app":

=LEFT("apple",3) returns "app"

The main challenge in this example is to calculate how many characters to extract, which is equal to the length of the last name. This is done with the FIND function like this:

FIND(",",B5)-1

FIND returns the location of text as a numeric position. Because the comma appears as the 6th character in the text, the FIND function returns 6. This is one more character than we need, so we subtract 1:

FIND(",",B5)-1 // returns 5

The result is 5, which is the length of the last name in "Chang, Amy". The code above returns this result directly to the LEFT function as the num_chars argument:

LEFT("Chang, Amy",5) // returns "Chang"

LEFT returns "Chang" as the final result. To extract the first name from names in column B see the formulas on this page.

Author

### Dave Bruns

Hi - I'm Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.