Moving the last name into a different column

dankar

Board Regular
Joined
Mar 23, 2016
Messages
113
Office Version
  1. 365
Platform
  1. Windows
I need help with the following, I have a list of 200+ name and I want to cut the last name and paste in the first column like the image.

I have 3 cases in all the names :
1. first name, middle name and last name ( I just want to remove the last name and paste it under last name column like first example in image)
2. First name and last name ( just want to remove the last name and paste it under last name column like second example in image )
3. Only first name. (just keep it as is)

Thanks.


Example.JPG
 

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.
Is it possible to have last name with two words, like "Von Trapp"?
If so, it is going to very difficult to tell if names with 3 or more words have 1 or 2 words in the last name.

Also, are you looking for a VBA solution?
Because formula solutions are going to be able to replace the data in the original column (column L), unless you were to do that manually.
Or, do you want to split the names from column L into two other columns (separate of column L)?
 
Upvote 0
Is it possible to have last name with two words, like "Von Trapp"?
If so, it is going to very difficult to tell if names with 3 or more words have 1 or 2 words in the last name.

Also, are you looking for a VBA solution?
Because formula solutions are going to be able to replace the data in the original column (column L), unless you were to do that manually.
Or, do you want to split the names from column L into two other columns (separate of column L)?
No for the last name is always one word.
if it will be easier to split them into two other columns, its ok..i can do it in a separate sheet then copy the results to the main one
VBA would be ok also, I'm not familiar with it but i will copy the code into Excel and try it..thanks for the help
 
Upvote 0
If your list of names starts in L1 and column K is empty then

VBA Code:
Sub jec()
 ar = Sheets(1).Range("K1", Sheets(1).Cells(Rows.Count, 12).End(xlUp))
 
 For i = 2 To UBound(ar)
   ar(i, 1) = Split(ar(i, 2))(UBound(Split(ar(i, 2))))
   ar(i, 2) = Replace(ar(i, 2), " " & ar(i, 1), "")
 Next
 
 Sheets(1).Range("K1", Sheets(1).Cells(Rows.Count, 12).End(xlUp)) = ar
End Sub
 
Upvote 0
With the given data Try

Book2
ABC
1Last NameFirst NameFirst Name Original
2MurrayChad Michael Chad Michael Murray
3LawsonRalph Ralph Lawson
4 SteveSteve
Sheet2
Cell Formulas
RangeFormula
A2:A4A2=IF(ISERROR(FIND(" ",C2)),"",TRIM(RIGHT(SUBSTITUTE(C2," ",REPT(" ",99)),99)))
B2:B4B2=REPLACE(C2,FIND(A2,C2),LEN(A2),"")
 
Upvote 0
If your list of names starts in L1 and column K is empty then

VBA Code:
Sub jec()
 ar = Sheets(1).Range("K1", Sheets(1).Cells(Rows.Count, 12).End(xlUp))
 
 For i = 2 To UBound(ar)
   ar(i, 1) = Split(ar(i, 2))(UBound(Split(ar(i, 2))))
   ar(i, 2) = Replace(ar(i, 2), " " & ar(i, 1), "")
 Next
 
 Sheets(1).Range("K1", Sheets(1).Cells(Rows.Count, 12).End(xlUp)) = ar
End Sub
Hi,

the list starts in L2 and column K is empty.

The list of names is over 250 name.

i deleted the first row of my to list (as its the header) so the list of names starts in L1 but this is what I got:

1630616257837.png
 
Upvote 0
With the given data Try

Book2
ABC
1Last NameFirst NameFirst Name Original
2MurrayChad Michael Chad Michael Murray
3LawsonRalph Ralph Lawson
4 SteveSteve
Sheet2
Cell Formulas
RangeFormula
A2:A4A2=IF(ISERROR(FIND(" ",C2)),"",TRIM(RIGHT(SUBSTITUTE(C2," ",REPT(" ",99)),99)))
B2:B4B2=REPLACE(C2,FIND(A2,C2),LEN(A2),"")
This one worked perfect, just the firs name in Column B came with a "space at the end of the name" how can I omit the space after each name, even if you will add another separate column its ok with me..thanks again
 
Upvote 0
Try

Moving the last name into a different column.xlsx
ABC
1Last NameFirst NameFirst Name Original
2MurrayChad MichaelChad Michael Murray
3LawsonRalphRalph Lawson
4 SteveSteve
Sheet3
Cell Formulas
RangeFormula
A2:A4A2=TRIM(IF(ISERROR(FIND(" ",C2)),"",TRIM(RIGHT(SUBSTITUTE(C2," ",REPT(" ",99)),99))))
B2:B4B2=TRIM(REPLACE(C2,FIND(A2,C2),LEN(A2),""))
 
Upvote 0
Solution
You may have to change your sheet name in the code.
 
Upvote 0

Forum statistics

Threads
1,215,483
Messages
6,125,063
Members
449,206
Latest member
Healthydogs

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