Split names into two columns: 1st column has 1st and middle name; 2nd column has the surname.

maxim642

Board Regular
Joined
Feb 4, 2021
Messages
91
Office Version
  1. 365
Platform
  1. MacOS
Full nameFirst & MiddleSurname
John Jack MurphyJohn JackMurphy
Mary-Joe SpencerMary-JoeSpencer
Jordan PetersJordanPeters
Jamie John-PaulJamieJohn-Paul

The tricky part is where some names have a hyphen (so they would be the first name), or other entries that don't have a middle name.

The above table provides examples of how it should look. I just don't know the formula to achieve it in the last two columns.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Hi maxim642,

Based on the assumption you need to find the position of the last space in a string, I adapted the formula from here to come up with the following (assumes the data starts in cell A2):

First & Middle Names: =TRIM(LEFT(A2,FIND("@",SUBSTITUTE(A2," ","@",(LEN(A2)-LEN(SUBSTITUTE(A2," ","")))/LEN(" ")))))
Surname: =TRIM(MID(A2,FIND("@",SUBSTITUTE(A2," ","@",(LEN(A2)-LEN(SUBSTITUTE(A2," ","")))/LEN(" "))),255))

Regards,

Robert
 
Upvote 0
Solution
Could you have names like "Jamie John Paul" where John Paul is the surname but doesn't have a hyphen?
 
Upvote 0
Could you have names like "Jamie John Paul" where John Paul is the surname but doesn't have a hyphen?
No, thankfully any double-barrel surnames/middle names are denoted with a hyphen. So, Jamie John Paul would be Jamie John (2nd column) Paul (3rd column).
 
Upvote 0
Hi maxim642,

Based on the assumption you need to find the position of the last space in a string, I adapted the formula from here to come up with the following (assumes the data starts in cell A2):

First & Middle Names: =TRIM(LEFT(A2,FIND("@",SUBSTITUTE(A2," ","@",(LEN(A2)-LEN(SUBSTITUTE(A2," ","")))/LEN(" ")))))
Surname: =TRIM(MID(A2,FIND("@",SUBSTITUTE(A2," ","@",(LEN(A2)-LEN(SUBSTITUTE(A2," ","")))/LEN(" "))),255))

Regards,

Robert
This is great, thank you.

In layman's terms, what exactly is this formula doing? And what is the significance of the 255 value in the Surname formula? Thanks again for your help, it solved the issue.
 
Upvote 0
No, thankfully any double-barrel surnames/middle names are denoted with a hyphen.
Ok, a similar approach, but this will spill across.
Fluff.xlsm
ABC
1Full nameFirst & MiddleSurname
2John Jack MurphyJohn JackMurphy
3Mary-Joe SpencerMary-JoeSpencer
4Jordan PetersJordanPeters
5Jamie John-PaulJamieJohn-Paul
Data
Cell Formulas
RangeFormula
B2:C5B2=LET(m,FIND("^",SUBSTITUTE(A2," ","^",(LEN(A2)-LEN(SUBSTITUTE(A2," ",""))))),CHOOSE({1,2},LEFT(A2,m-1),MID(A2,m+1, LEN(A2))))
Dynamic array formulas.
 
Upvote 0
Ok, a similar approach, but this will spill across.
.. or it could spill both down and across per the top section below with just a single formula in B2, or if the latest text-splitting functions are available then the shorter formula in B8 below will also spill down and across.

22 06 07.xlsm
ABC
1Full nameFirst & MiddleSurname
2John Jack MurphyJohn JackMurphy
3Mary-Joe SpencerMary-JoeSpencer
4Jordan PetersJordanPeters
5Jamie John-PaulJamieJohn-Paul
6
7Full nameFirst & MiddleSurname
8John Jack MurphyJohn JackMurphy
9Mary-Joe SpencerMary-JoeSpencer
10Jordan PetersJordanPeters
11Jamie John-PaulJamieJohn-Paul
Split Names
Cell Formulas
RangeFormula
B2:C5B2=LET(r,A2:A5,s,TRIM(RIGHT(SUBSTITUTE(r," ",REPT(" ",50)),50)),CHOOSE({1,2},LEFT(r,LEN(r)-LEN(s)-1),s))
B8:C11B8=CHOOSE({1,2},TEXTBEFORE(A8:A11," ",-1),TEXTAFTER(A8:A11," ",-1))
Dynamic array formulas.
 
Upvote 0
Ok, a similar approach, but this will spill across.
Fluff.xlsm
ABC
1Full nameFirst & MiddleSurname
2John Jack MurphyJohn JackMurphy
3Mary-Joe SpencerMary-JoeSpencer
4Jordan PetersJordanPeters
5Jamie John-PaulJamieJohn-Paul
Data
Cell Formulas
RangeFormula
B2:C5B2=LET(m,FIND("^",SUBSTITUTE(A2," ","^",(LEN(A2)-LEN(SUBSTITUTE(A2," ",""))))),CHOOSE({1,2},LEFT(A2,m-1),MID(A2,m+1, LEN(A2))))
Dynamic array formulas.
Thanks, this also works. This formula blows my mind! Great stuff!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Here is an alternative means to your end with Power Query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Full name", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, true), {"Full name.1", "Full name.2"}),
    #"Renamed Columns" = Table.RenameColumns(#"Split Column by Delimiter",{{"Full name.1", "First Middle"}, {"Full name.2", "Last"}})
in
    #"Renamed Columns"
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,141
Members
453,021
Latest member
Justyna P

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