What's wrong with this formula?

TWTHOMAS

Board Regular
Joined
Mar 26, 2010
Messages
96
I have a personnel data sheet that contains names of employees in column C of sheet named awards_civic_length_of_service.

Usually like - Jones, Bob E JR

Due to inconsistencies of spaces during input I use this formula in A2 of sheet 2 to bring the names into my data.

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(awards_civic_length_of_service_!C2,", "," "),"JR"," JR"),"II"," II"),"III"," III"),"SR"," SR")

I then extract the first name, middle initial, last name and suffix into columns B, C, D, E of sheet 2

It works great with one exception and I cannot figure out why.

Column D of sheet 2 contains this formula.

=TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",100)),300,100))

But Column D will not show my JR's and SR's and II's and III's unless I go to the original awards_civic_length_of_service and rid myself of ALL spaces between the middle initial and the suffix.

So the name looks like - Jones, Bob EJR

Any idea why I have to remove those spaces completely?
 
Last edited:

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, just curious, in the sample you provided, 'Jones, Bob E JR' each string is separated by one (1) space. Are you referring to instances where the data is encoded or imported (from the web) with additional space?
Is your intention to remove all unnecessary space while retaining one (1) space to separate each string?
 
Upvote 0
Such as this:


Excel 2013
ABCDE
1Jones, Bob E JRJonesBobEJR
2Jones, Bob E JRJonesBobEJR
3Jones, Bob E JRJonesBobEJR
TWTHOMAS
 
Upvote 0
That is exactly what I need to do.

I need to extract the last, first, middle, and suffix (if one exists) from a mixture of names that have varying
numbers of spaces in them.

Also where some have all 4 and some just have a First and Last name.
 
Upvote 0
That is exactly what I need to do.

I need to extract the last, first, middle, and suffix (if one exists) from a mixture of names that have varying
numbers of spaces in them.

Also where some have all 4 and some just have a First and Last name.
Try this:

Excel 2013
ABCDE
1Jones, Bob E JRJonesBobEJR
2Jones, Bob E JRJonesBobEJR
3Jones, Bob E JRJonesBobEJR
4, ,Jones , Bob, ,,, , , E, JR,,, ,JonesBobEJR
TWTHOMAS
Cell Formulas
RangeFormula
B1=TRIM(MID(SUBSTITUTE(TRIM(SUBSTITUTE($A1,","," "))," ",REPT(" ",99)),COLUMNS($B1:B1)*99-98,99))
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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