Stripping off duplicate string by comparing two columns

blackystrat

New Member
Joined
Aug 5, 2014
Messages
26
Hello

So I have a spreadsheet (Excel 2013) with two columns for Firm Names and Address. Now for several entries, the firm name is present in both the firm name and the address column.

How can I compare these two columns and strip off the firm names from the address column?

How I have it

[TABLE="class: outer_border, width: 500"]
<tbody>[TR]
[TD]Name[/TD]
[TD]Firm[/TD]
[TD]Address[/TD]
[/TR]
[TR]
[TD]John Reeds[/TD]
[TD]J.R Trading Inc[/TD]
[TD]J.R Trading Inc, 98 Park Avenue[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

How I Want
[TABLE="class: outer_border, width: 500, align: left"]
<tbody>[TR]
[TD]Name[/TD]
[TD]Firm[/TD]
[TD]Address[/TD]
[/TR]
[TR]
[TD]John Reeds[/TD]
[TD]J.R Trading Inc[/TD]
[TD]98 Park Avenue[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]





Many thanks in advance

Regards
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Here's one way:

Enter in D2 and fill down : =IF(B2=LEFT(C2,LEN(B2)),RIGHT(C2,LEN(C2)-LEN(B2)-2),C2)
Convert column D to values
Delete column C
 
Upvote 0
Thanks footoo and Yongle - both of your formula works perfectly. However, there are some formatting anomalies in the data for which I still have to do some manual work but these helped to a large extent.

Many thanks again
 
Upvote 0
Or VBA code making use of Yongle's formula:
Code:
Dim r&: r = Cells(Rows.Count, "C").End(xlUp).Row
Dim b$: b = Range([B2], Cells(r, "B")).Address
Dim c$: c = Range(b).Offset(, 1).Address
Range(c) = Evaluate("index(trim(substitute(" & c & "," & b & "&"", "","""")),)")
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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