Replace letters with exceptions

bluefuel318

New Member
Joined
Feb 8, 2007
Messages
30
I have a column that contains part numbers along with text, for example:

Pack 78101119220
Paint 78101118835
Pack ABC8620130
Dip ABCD8620131

I would like a macro to do a replace/delete/etc that would remove all letters from the column except for those within a part number, essentially leaving just the part number. In other words, replace all letters with blanks except for instances of "ABC" or "ABCD", which would leave the list above as:

78101119220
78101118835
ABC8620130
ABCD8620131


Anyone have any ideas?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Would this be an accurate description of what you want?

I want the text to the right of the last space in the cell.


If so, try

=TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1)))
 
Upvote 0
Yes, the second works perfectly! (The first works, too, but if there is more than one word other than the material number in the cell, then the second one takes care of both). Thank you both so much!!!
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,254
Members
452,900
Latest member
LisaGo

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