Extract Last Name

shivya

New Member
Joined
Feb 1, 2016
Messages
1
Hello to all,

This is my Raw Data, I have to extract firstname, middlename and lastname in seperate column.

First Name = =LEFT(A16,SEARCH(" ",A16))

Last Name = =RIGHT(A17,LEN(A17)-SEARCH(" ",A17))

Full Name
First NameMiddle NameLast Name
Shivya JainShivya Jain
Shweta JainShweta Jain
Mohan Prakash SharmaMohan Prakash Sharma
Juhi ChawlaJuhi Chawla


<colgroup><col><col><col><col></colgroup><tbody>
</tbody>

Last Name is not working Properly. Please help me out.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Your
Code:
Search(" ",A17)
is still looking at the very first space in the string rather than the second space. Works fine for the full names without a middle one - there's only one space to worry about, but it isn't picking up that 2nd space later in the string. Try replacing the formula for the Last Name to this:
Code:
=RIGHT(A17,LEN(A17)-IF(ISERROR(SEARCH(" ",A17,SEARCH(" ",A17)+1)),SEARCH(" ",A17),SEARCH(" ",A17,SEARCH(" ",A17)+1)))

The
Code:
Search(" ",A17,Search(" ",A17)+1)
begin another search 1 character after the first space in the full name. The IF statement determines if there are 2 or 3 total names, and uses the corresponding search function.

You can put this in the middle name column. Let me know if there's any issue with it.
Code:
=IF(ISERROR(SEARCH(" ",A17,SEARCH(" ",A17)+1)),"",MID(A17,SEARCH(" ",A17)+1,SEARCH(" ",A17,SEARCH(" ",A17)+1)-SEARCH(" ",A17)-1))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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