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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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,980
Messages
6,122,563
Members
449,088
Latest member
Motoracer88

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