Return Characters Surrounding Specific Character

Tap13

New Member
Joined
Apr 13, 2010
Messages
35
I have a series of data that resides in my A column and somewhere in each portion is a persons name. The data typically appears like this:

1083Ak2 Smith, Joe 34kl 1000

What I would like to do is have a formula in B1 that returns "Smith, Joe". Right now my code is:
Code:
=Trim(MID(A1,Find(",",A1) -12,25))

It works to return the name but because it uses a literal number of characters to work with it periodically returns something like:

AK2 Smith, Joe 34k

Can I somehow return the characters surrounding the comma, but only until it hits a space?

Thanks for everyones help on this.
 

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.
This will return the text between the 1st and 3rd space characters in the original text.

=TRIM(MID(SUBSTITUTE(A1," ",REPT(" ", 100)),100,200))
 
Upvote 0
Does the name always start after the first space character?

If not, then you would need to find a way to find the first space before the comma and then the second space after the comma. I don't know of a way to do this with a formula. I haven't found a way to use find before the comma. I'm sure it could be done with VBA if this is an option for you.
 
Upvote 0
There are many spaces throughout the data. The only thing that is constant is that the layout for names is always "Last, First", beyond that there is a lot of fluctuation.
 
Upvote 0
This will return the text (names) surrounding the 1st comma.
Code:
=TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",100)),FIND(",",SUBSTITUTE(A1," ",REPT(" ",100)))-100,300))
 
Upvote 0
Very creative. I didn't know that trim also removed internal spaces.

This could fail if the name is really, really, really long, but that should never happen.
 
Upvote 0
PERFECT! You sir are fantastic. That worked perfectly. Appreciate your quick response too, thank you.
 
Upvote 0

Forum statistics

Threads
1,224,570
Messages
6,179,611
Members
452,931
Latest member
The Monk

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