Extracting last name from full name

bearcub

Well-known Member
Joined
May 18, 2005
Messages
734
Office Version
  1. 365
  2. 2013
  3. 2010
  4. 2007
Platform
  1. Windows
I have to extract the last name and join it with elements to create a position title that is used in an application.

This is the formula:

TRIM(E10&"-"&F10&"-"&UPPER(RIGHT(A10,SEARCH(" ",A10))))&"-"&G10

The issue I am having with is in the Upper(Right) section that extracts the last name from the name.

The formula works okay until I have people a middle name, etc. The formula works well only if their are 2 works. The formula goes wonky when I have a 1st, middle & last name.

Is there a formula that will find the last space in the name and extract the last name? Note row 10, this person has 4 names instead of 2. And the result is including the 2nd, 3rd & 4th words of the name.

This is the source data and results (Column C)

Cell Formulas
RangeFormula
C11=TRIM(E11&"-"&F11&"-"&UPPER(RIGHT(A11,SEARCH(" ",A11))))&"-"&G11
Press CTRL+SHIFT+ENTER to enter array formulas.
XD]C11[/XD]
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Using Flash fill in Excel.
Type the last name in the first cell, type the last name in the second cell. Flash fill get last name for all cells. Make the correction to the Gener name. Done, Flash fill considers those patterns to fill all the cells.

 
Last edited:
Upvote 0
Thank you. Does Flash fill join different columns? I am joining several cells and using "-" to create the position name?

I think I did find a formula that works. I'm wondering if their is a simplier formula that I have for the right function:

=TRIM(E3&"-"&F3&"-"&UPPER(RIGHT(A3,LEN(A3)-FIND("*",SUBSTITUTE(A3," ","*",LEN(A3)-LEN(SUBSTITUTE(A3," ","")))))&"-"&G3))


2023 New Hires and Terminations.xlsb
ABCDEFG
1Month:Oct 22
2EmployeeStart DatePositionDeptRegionFunctionEMP ID
3Veronika Westerlund10/3/2022EMEA-SALES-WESTERLUND-7F7R8MA6K430000EMEASALES7F7R8MA6K
Oct 22
 
Upvote 0
Try :

varios 26oct2022.xlsm
ABCDEFG
1Month:oct-22
2EmployeeStart DatePositionDeptRegionFunctionEMP ID
3Veronika WesterlundEMEA-SALES-Westerlund-7F7R8MA6K43000EMEASALES7F7R8MA6K
4Andy DedmanEMEA-SALES-Dedman-7F7R8MA6K43001EMEASALES7F7R8MA6K
5Roberta PolesiEMEA-SALES-Polesi-7F7R8MA6K43002EMEASALES7F7R8MA6K
6Gener Javier Perez TorresEMEA-SALES-Javier Perez Torres-7F7R8MA6K43003EMEASALES7F7R8MA6K
7Darrick WebsterEMEA-SALES-Webster-7F7R8MA6K43004EMEASALES7F7R8MA6K
8Dante Amor MendiolaEMEA-SALES-Amor Mendiola-7F7R8MA6K43005EMEASALES7F7R8MA6K
9Brandon JacksonEMEA-SALES-Jackson-7F7R8MA6K43006EMEASALES7F7R8MA6K
10Jatinder LuthraEMEA-SALES-Luthra-7F7R8MA6K43007EMEASALES7F7R8MA6K
11Hervé TchahaEMEA-SALES-Tchaha-7F7R8MA6K43008EMEASALES7F7R8MA6K
12Thore RabeEMEA-SALES-Rabe-7F7R8MA6K43009EMEASALES7F7R8MA6K
Hoja7
Cell Formulas
RangeFormula
C3:C12C3=E3&"-"&F3&"-"&TRIM(MID(SUBSTITUTE(A3," ",REPT(" ",99),1),99,99))&"-"&G3
 
Upvote 0
Book1
ABCDEFG
2EmployeeStart DatePositionDeptRegionFunctionEMP ID
3Veronika WesterlundEMEA-SALES-Westerlund-7F7R8MA6K43000EMEASALES7F7R8MA6K
4Andy DedmanEMEA-SALES-Dedman-7F7R8MA6K43001EMEASALES7F7R8MA6K
5Roberta PolesiEMEA-SALES-Polesi-7F7R8MA6K43002EMEASALES7F7R8MA6K
6Gener Javier Perez TorresEMEA-SALES-Torres-7F7R8MA6K43003EMEASALES7F7R8MA6K
7Darrick WebsterEMEA-SALES-Webster-7F7R8MA6K43004EMEASALES7F7R8MA6K
8Dante Amor MendiolaEMEA-SALES-Mendiola-7F7R8MA6K43005EMEASALES7F7R8MA6K
9Brandon JacksonEMEA-SALES-Jackson-7F7R8MA6K43006EMEASALES7F7R8MA6K
10Jatinder LuthraEMEA-SALES-Luthra-7F7R8MA6K43007EMEASALES7F7R8MA6K
11Hervé TchahaEMEA-SALES-Tchaha-7F7R8MA6K43008EMEASALES7F7R8MA6K
12Thore RabeEMEA-SALES-Rabe-7F7R8MA6K43009EMEASALES7F7R8MA6K
Sheet1
Cell Formulas
RangeFormula
C3:C12C3=E3&"-"&F3&"-"&TRIM(RIGHT(SUBSTITUTE(A3," ",REPT(" ",100)),100))&"-"&G3
 
Upvote 0
Solution
Is there a formula that will find the last space in the name and extract the last name? Note row 10, this person has 4 names instead of 2.
In the case of 2 words you want the second.
In the case of 3 words, which ones do you want?
In the case of 4 words, which ones do you want?
The names in Spanish include more than 4 words, they can have up to 7 or more words, in those cases how many words do you want?
 
Upvote 0
I always only the last name. We normally have reps that have a first and last name but, as you can by the example, we have a new hire that has 4 names. I want the formula to strip everything away except for Torres.
 
Upvote 0
This formula works well too: TRIM(RIGHT(SUBSTITUTE(A3," ",REPT(" ",100)),100)). Is this formula increasing the number of spaces to the left of Torres so that only Torres is returned?
 
Upvote 0
This formula works well too: TRIM(RIGHT(SUBSTITUTE(A3," ",REPT(" ",100)),100)). Is this formula increasing the number of spaces to the left of Torres so that only Torres is returned?
Did you mention to my formula in #5?
Last space is replaced with 100 spaces, to make sure last 100 letters include space and "Torres", like: " Torres"
Then using TRIM to get "Torres"
 
Upvote 0
THis just take DanteAmor's excellent work, and slightly adapts it. You can see the new "Last Name" column on the right, but I've added the new formula into Column C to demonstrate how it works.
Book1
ABCDEFGH
1EmployeeStart DatePositionDeptRegionFunctionEMP IDLastName
2Veronika WesterlundEMEA-SALES-Westerlund-7F7R8MA6K43000EMEASALES7F7R8MA6KWesterlund
3Andy DedmanEMEA-SALES-Dedman-7F7R8MA6K43001EMEASALES7F7R8MA6KDedman
4Roberta PolesiEMEA-SALES-Polesi-7F7R8MA6K43002EMEASALES7F7R8MA6KPolesi
5Gener Javier Perez TorresEMEA-SALES-Torres-7F7R8MA6K43003EMEASALES7F7R8MA6KTorres
6Darrick WebsterEMEA-SALES-Webster-7F7R8MA6K43004EMEASALES7F7R8MA6KWebster
7Dante Amor MendiolaEMEA-SALES-Mendiola-7F7R8MA6K43005EMEASALES7F7R8MA6KMendiola
8Brandon JacksonEMEA-SALES-Jackson-7F7R8MA6K43006EMEASALES7F7R8MA6KJackson
9Jatinder LuthraEMEA-SALES-Luthra-7F7R8MA6K43007EMEASALES7F7R8MA6KLuthra
10Hervé TchahaEMEA-SALES-Tchaha-7F7R8MA6K43008EMEASALES7F7R8MA6KTchaha
11Thore RabeEMEA-SALES-Rabe-7F7R8MA6K43009EMEASALES7F7R8MA6KRabe
Sheet1
Cell Formulas
RangeFormula
C2:C11C2=E2&"-"&F2&"-"&RIGHT(A2,LEN(A2)-FIND("*",SUBSTITUTE(A2," ","*",LEN(A2)-LEN(SUBSTITUTE(A2," ","")))))&"-"&G2
H2:H11H2=RIGHT(A2,LEN(A2)-FIND("*",SUBSTITUTE(A2," ","*",LEN(A2)-LEN(SUBSTITUTE(A2," ","")))))
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,312
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top