How do I rearrange the order of words in a cell, consistently?

smart analyst

New Member
Joined
Mar 27, 2018
Messages
7
Hi all,

I am trying to rearrange a mass list of names in a cell. The good thing is that all of the names are formatted similarly that is:

"Last-name, first-name"

Each cell starts with the last name and then has a comma, and then includes their first name.


So for John Smith (Smith, John) - is there any way I can put in a formula to rearrange the cell to read "John, Smith"?


Thanks
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
What about:
Code:
=RIGHT(A1,FIND(",",A1)-2)&", "&LEFT(A1,FIND(",",A1)-1)
 
Upvote 0
What if a name has 3 words. Rembrandt van Rijn
 
Upvote 0
Whenever you have a 3 word name, you could use this UDF (behind a module).

VBA Code:
Function jec(cell As String) As String
c00 = Trim(Split(cell, ",")(UBound(Split(cell, ","))))
jec = c00 & ", " & Replace(Replace(cell, ",", ""), c00, "")
End Function

Excel Formula:
=jec(A1)
 
Upvote 0
This will handle it:

=SUBSTITUTE(MID(A1&" "&A1,FIND(",",A1)+2,LEN(A1)-1), " ", ", ", 1)
 
  • Like
Reactions: JEC
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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