remove characters from a string

p4nny

Board Regular
Joined
Jan 13, 2015
Messages
246
Hi

I have the following info in cells a2:a5

Andrew Lee Jones
Ken David Thompson
Chris Smith
David Stephen Scott


I would like to keep the last name.. So keep, Jones, Thompson, smith, Scott

Please coud you show me the best way of doing this
 

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.
Hi.

Is there any way of knowing whether, for a given name, the second-to-last word is that person's middle name or part of the surname?

For example, in "Robin van Persie", "van" is actually part of his last name, so you should keep "van Persie" in that case.

However, in "David Stephen Scott", you would only keep "Scott".

How can we tell Excel to keep the second-to-last name in certain cases and not in others? Or would you be happy to take the chance that you will never have any examples like "van Persie" in your data and so always just take the last word?

Regards
 
Upvote 0
I understand where you are coming from and thanks for pointing that out because I hadn't thought of that.

In this scenrio, it is purely the surname.

Cheers
 
Upvote 0
This is visually shorter:

=TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1)))

though this, despite being longer, may actually calculate more quickly:

=RIGHT(A1,LEN(A1)-FIND("ζ",SUBSTITUTE(A1," ","ζ",LEN(A1)-LEN(SUBSTITUTE(A1," ","")))))

Regards
 
Upvote 0
p4nny,

How about something like this:


Excel 2007
AB
1
2Andrew Lee JonesJones
3Ken David ThompsonThompson
4Chris SmithSmith
5David Stephen ScottScott
6
Sheet1
Cell Formulas
RangeFormula
B2=TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",255)),255))


The formula in cell B2, copied down:

=TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",255)),255))
 
Upvote 0

Forum statistics

Threads
1,216,228
Messages
6,129,617
Members
449,520
Latest member
TBFrieds

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