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:

[TABLE="width: 926"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]Part[/TD]
[TD]Description[/TD]
[/TR]
[TR]
[TD]03700-38/40[/TD]
[TD]03700-38/40 Volkl Rescue zip RITS maat 38-40[/TD]
[/TR]
[TR]
[TD]03700-41/43[/TD]
[TD]03700-41/43 Volkl Rescue zip RITS maat 41-43[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 926"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]
How we want the data:

[TABLE="width: 926"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD][TABLE="width: 926"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]Part[/TD]
[TD]Description[/TD]
[/TR]
[TR]
[TD]03700-38/40[/TD]
[TD]Volkl Rescue zip RITS maat 38-40[/TD]
[/TR]
[TR]
[TD]03700-41/43[/TD]
[TD]Volkl Rescue zip RITS maat 41-43[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Any help, would be much appreciated.

Jonathan[/TD]
[TD]

[/TD]
[/TR]
</tbody>[/TABLE]

[/TD]
[TD]

[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
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,223,783
Messages
6,174,524
Members
452,569
Latest member
Ron1970

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