Need formula to split names/column

Sm3tUser

New Member
Joined
Apr 13, 2015
Messages
11
I have a column with names in it. I need to split them into two columns, however I can't use Text to Columns because the names are all formatted differently:

John Smith
John & Melinda Smith
John Harold Smith
John Harold Abel Smith

<tbody>
</tbody>

The above example needs to look like this:

JohnSmith
John & MelindaSmith
JohnHarold Smith
JohnHarold Abel Smith

<tbody>
</tbody>

I need a way to break it up on the following conditions:


- If the cell contains an & symbol, break the column after the third space - FirstName & PartnerFirstName | LastName
- If the cell does not contain an & symbol, break it after the first space.

When I asked this question awhile ago, I had someone give me this formula:

B1:
=IF(ISNUMBER(SEARCH("&",$A3)),TRIM(MID(SUBSTITUTE($A3," ",REPT(" ", 100)),1,300)),TRIM(MID(SUBSTITUTE($A3," ",REPT(" ", 100)),1,100)))

C1:
=IF(ISNUMBER(SEARCH("&",$A2)),TRIM(MID(SUBSTITUTE($A2," ",REPT(" ", 100)),300,100)),TRIM(MID(SUBSTITUTE($A2," ",REPT(" ", 100)),100,100)))

Unfortunately on names such as 'John Harold Smith' (3 or more word names without '&' symbols) were formatted incorrectly. The above example turned into:

JohnCharles

<tbody>
</tbody>

Any help would be appreciated! Thanks
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Assuming your names start in cell A1, put these formulas in the indicated cells and copy down...

B1: =TRIM(LEFT(SUBSTITUTE(TRIM(A1)," ",REPT(" ",200)),(1+2*(COUNTIF(A1,"*&*")>0))*200))

C1: =MID(A1,LEN(B1)+1,200)
 
Upvote 0

Forum statistics

Threads
1,215,580
Messages
6,125,654
Members
449,245
Latest member
PatrickL

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