Removing value in column A from sub-string in column B

Jonathan Jones

New Member
Joined
Jul 30, 2017
Messages
18
Hi,

I have a list of product codes in column A, and a list of product descriptions in column B. On many rows the product descriptions contains the product code. On rows where the product decription contains the product code, I would like to remove the product code. Example below:

Data is currently:

PartDescription
03700-38/4003700-38/40 Volkl Rescue zip RITS maat 38-40
03700-41/4303700-41/43 Volkl Rescue zip RITS maat 41-43

<colgroup><col><col></colgroup><tbody>
</tbody>

How we want the data:

PartDescription
03700-38/40Volkl Rescue zip RITS maat 38-40
03700-41/43Volkl Rescue zip RITS maat 41-43

<colgroup><col><col></colgroup><tbody>
</tbody>
Any help, would be much appreciated.

Jonathan



<colgroup><col><col></colgroup><tbody>
</tbody>




<colgroup><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Heres a formula that does but it obviously needs to go in another cell. If you need to overwrite the description then you would need code.

=TRIM(SUBSTITUTE(B2,A2,""))
 
Last edited:
Upvote 0
As steve mentioned, if you need code try the below

Code:
Sub test()
Dim addrA As String, addrB As String
 addrA = "A2:A" & Range("A" & Rows.Count).End(xlUp).Row


 addrB = "B2:B" & Range("B" & Rows.Count).End(xlUp).Row


  Range(addrB).Value = Evaluate(Replace("IF(ISNUMBER(SEARCH(" & addrA & ",@)),TRIM(SUBSTITUTE(@," & addrA & ","""")),@)", "@", addrB))
End Sub
 
Upvote 0
As steve mentioned, if you need code try the below

Code:
Sub test()
Dim addrA As String, addrB As String
 addrA = "A2:A" & Range("A" & Rows.Count).End(xlUp).Row


 addrB = "B2:B" & Range("B" & Rows.Count).End(xlUp).Row


  Range(addrB).Value = Evaluate(Replace("IF(ISNUMBER(SEARCH(" & addrA & ",@)),TRIM(SUBSTITUTE(@," & addrA & ","""")),@)", "@", addrB))
End Sub

Brilliant - thank you!
 
Upvote 0

Forum statistics

Threads
1,216,094
Messages
6,128,785
Members
449,468
Latest member
AGreen17

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