Delete Text before space if exists

joferder

Board Regular
Joined
Dec 18, 2005
Messages
59
I have a list of names that I need to remove the first name if it exists. Not all of them will have it. My list may looks like this:


John Doe
Steven Smith
Johnson

I found this formula:


=MID(A2,FIND(" ",A2)+1,256)

The problem is, that if there is no first name (so no space), it will give me a #VALUE ! error.

Any ideas of what I can use to remove just the first names if it is there would be greatly appreciated.

John
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Try:


Excel 2013/2016
AB
1John DoeDoe
2Steven SmithSmith
3JohnsonJohnson
Sheet1
Cell Formulas
RangeFormula
B1=IFERROR(RIGHT(A1,LEN(A1)-SEARCH(" ",A1)),A1)
 
Upvote 0
One more question. Is there a way to make it so that it will not remove the characters before the space if there is a period in it? I have a name that is St. John as a last name, so I would need the "St." on there, but this may also apply if I have a first initial.

It's not a big thing, just kind of wondering.

John
 
Upvote 0
One more question. Is there a way to make it so that it will not remove the characters before the space if there is a period in it? I have a name that is St. John as a last name, so I would need the "St." on there, but this may also apply if I have a first initial.

It's not a big thing, just kind of wondering.

John

Try:


Excel 2013/2016
AB
1John DoeDoe
2Steven SmithSmith
3JohnsonJohnson
4St. JohnSt. John
Sheet4
Cell Formulas
RangeFormula
B1=IFERROR(IF(ISNUMBER(SEARCH(".",LEFT(A1,SEARCH(" ",A1)))),A1,RIGHT(A1,LEN(A1)-SEARCH(" ",A1))),A1)
 
Upvote 0
Is there a way to make it so that it will not remove the characters before the space if there is a period in it? I have a name that is St. John as a last name, so I would need the "St." on there, but this may also apply if I have a first initial.
Does this do what you want...

=IFERROR(IFERROR(IF(FIND(".",A1)=2,MID(A1,FIND(" ",A1)+1,99),A1),MID(A1,FIND(" ",A1)+1,99)),A1)
 
Upvote 0

Forum statistics

Threads
1,217,413
Messages
6,136,478
Members
450,016
Latest member
murarj

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