Remove characters from string only if they are certain characters

megera716

Board Regular
Joined
Jan 3, 2013
Messages
139
Office Version
  1. 365
Platform
  1. Windows
Our dental insurance carrier's bill formatting is THE WORST and I jump through 37 hoops using LEFT, TEXTAFTER and text to columns to make it usable for reconciliation every month.

One thing I haven't been able to automate so I've been fixing manually is some employees have a letter after their name, which looks like a middle initial but it is not an initial, it's a reason code. But others don't have this letter code at all so I can't just lop off the last 2 characters of every cell. Here is a list of employee names, last name first, with every letter except their first and last initial replaced by me with an asterisk for purposes of this post.

The letter, if they have one, is "A", "R" or "T". There is a space but no punctuation between the last letter of their first name and the reason code. I would like to remove the space AND the letter so I don't have to run yet another function (TRIM) to clean this freaking thing up every month. The first employee name is in cell A2.

C*****, K****** A
C***, C*******
C******, M*** A
M****, J*** A
M******, V****** M**** R
N***, W****
N*****, M******
B****, C****** T
B*******, M****** A
B****, K**** T
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Upvote 1
Solution
How about
Fluff.xlsm
AB
1
2C*****, K****** AC*****, K******
3C***, C*******C***, C*******
4C******, M*** AC******, M***
5M****, J*** AM****, J***
6M******, V****** M**** RM******, V****** M****
7N***, W****N***, W****
8N*****, M******N*****, M******
9B****, C****** TB****, C******
10B*******, M****** AB*******, M******
11B****, K**** TB****, K****
Sheet3
Cell Formulas
RangeFormula
B2:B11B2=TEXTBEFORE(A2&" ",{" A "," R "," T "},,,1)
THANK YOU. I could cry tears of joy! I had 443 rows of employees with or without the code and this did it all in one second.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,707
Members
448,981
Latest member
recon11bucks

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