removing special characters

johnmerlino

Board Regular
Joined
Sep 21, 2010
Messages
94
Hey all, right now I have this excel calculation:
Code:
[SIZE=2]=IF( ISERROR( SEARCH("&", A1) ), IF( ISERROR( SEARCH(" ", A1) ), A1, LEFT(A1,LOOKUP(2^15,FIND(" ",A1,ROW(INDIRECT("1:"&LEN(A1)))))-1)),SUBSTITUTE(A1,MID(A1,FIND(",",A1,1)+1,FIND("&",A1,1)-FIND(",",A1,1)),""))[/SIZE]
This effectively converts the below:
AVERNA,ROBERT C H/E
Corn,Marlin
Lizand,ROBERT H
CATANESE,SALVATORE J & OLGA M
JIMENEZ,ALEJANDRO & HILDA M

into this:

AVERNA,ROBERT C
Corn,Marlin
Lizand,ROBERT H
CATANESE,OLGA M
JIMENEZ,HILDA M

Hence, if there is a character after middle initial or middle name, it is stripped out, and if there is no middle initial, full nam is kept, and if there is an & sign the first name and middle initial to the right of & sign along with the last name to the left is brought into its own column.

I am having an issue in that there are 3 special strings (REV, TR, H/E) that must always be removed. So even if the middle name or initial is REV or TR or H/E, it doesn't matter. I want to remove them. In other words:

This:
Corn,Marlin REV TR H/E
White,Alexia & John M REV TR

needs to be converted to this:

Corn,Marlin
White,John M

And I would like to to be part of the existing query I have:
Code:
[SIZE=2]=IF( ISERROR( SEARCH("&", A1) ), IF( ISERROR( SEARCH(" ", A1) ), A1, LEFT(A1,LOOKUP(2^15,FIND(" ",A1,ROW(INDIRECT("1:"&LEN(A1)))))-1)),SUBSTITUTE(A1,MID(A1,FIND(",",A1,1)+1,FIND("&",A1,1)-FIND(",",A1,1)),""))[/SIZE]
Thanks for any response.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
If you use Find and Replace to replace " H/E", " TR", " REV" with a space, wouldn't it be good enough for you?
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,752
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