sort names by last name

dshafique

Board Regular
Joined
Jun 19, 2017
Messages
171
Hi guys, i have a set of data where the whole name is one cell, including the middle name. I want a formula which will organize it by last name, first name middle name. I have one formula which does something similar, but it gives me an error for cells that contain one word, like vacant, or something/guest

here's the formula i have

Code:
=MID(A2&", "&A2,FIND(" ",A2,FIND(" ",A2)+COUNTIF(A2,"* * *"))+1,LEN(A2)+1)
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try this

=IF(ISNUMBER(SEARCH(" ",A2))=TRUE,RIGHT(A2,LEN(A2)-FIND(" ",A2))& " " & LEFT(A2,FIND(" ",A2)-1),A2)
 
Last edited:
Upvote 0
You can use IFERROR instead of IF:
Code:
=IFERROR(MID(A2,FIND(" ",A2),LEN(A2))&LEFT(A2,FIND(" ",A2)),A2)
 
Upvote 0
This is a good formula, but I would like to add ; at the end. I can't find where to put &";" ?????
I need Last, First M;

Don't as why . . . . . . long story . . . .
 
Upvote 0
This is a good formula,..
Which one - there have been several suggested. :)

Could we have a small set of sample data and your expected results so we can see exactly what you have and what you want?
Might you have Last Names consisting of more than one word like "de Bruyn" or "van der Halen"?
 
Last edited:
Upvote 0
I have names as First M Last (some don't have M, so there will be a " " there)
Here is the formula I've been using and I figured out how to add the ";" at the end:
=MID(A2&", "&A2,FIND(" ",A2,FIND(" ",A2)+COUNTIF(A2,"* * *"))+1,LEN(A2)+1)&";"

Result:
First M Last - returns - Last, First M; (just what I wanted)
But, First "space" Last - returns - "space"Last, First"space";
 
Upvote 0
Well, you could try this - but you didn't answer my last question. ;)

<b>Re-Order Names</b><br /><br /><table border="1" cellspacing="0" cellpadding="0" style="font-family:Arial,Arial; font-size:8pt; background-color:#ffffff; padding-left:2pt; padding-right:2pt; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:110px;" /><col style="width:123px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td></tr><tr style="height:21px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td style="font-size:10pt; ">First M Last</td><td style="font-size:10pt; ">Last, First M;</td></tr><tr style="height:21px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td style="font-size:10pt; ">First   Last</td><td style="font-size:10pt; ">Last, First;</td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b>Spreadsheet Formulas</b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Formula</td></tr><tr><td >B2</td><td >=TRIM(MID<span style=' color:008000; '>(SUBSTITUTE<span style=' color:#0000ff; '>(A2&", "&A2,"   ","  ")</span>,FIND<span style=' color:#0000ff; '>(" ",A2,FIND<span style=' color:#ff0000; '>(" ",A2)</span>+1)</span>+1,LEN<span style=' color:#0000ff; '>(A2)</span>+1)</span>)&";"</td></tr></table></td></tr></table>
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,300
Members
452,633
Latest member
DougMo

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