Remove matching data across columns

WatfordKev

Board Regular
Joined
Mar 30, 2011
Messages
78
I have two columns, one of which may have repeated data from the other one which I would like to remove / delete... have tried to get this working myself but admitting defeat here!

for example:

A1 contains abcd
B1 contains abcd efgh ijkl mnop

I would like to remove abcd (and the trailing space!) from B1 which would then consist of efgh ijkl mnop

If A1 were to be blank then leave B1 as is.
If A1 contained no match in B1 then also leave B1 as is.

Thanks in advance for any help!
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
1. Would the text in A1 always be a whole 'word' in B1. What I am getting at is if
A1 = apple
B2 = I have an apple and a pineapple

then VoG's formula would result in
I have an and a pine

Is that what you would want?

2. VoG's formula would produce a result in another column. Is that okay or were you looking to actually change the values that are in column B? To do that would require vba code.
 
Upvote 0
1. Would the text in A1 always be a whole 'word' in B1. What I am getting at is if
A1 = apple
B2 = I have an apple and a pineapple

then VoG's formula would result in
I have an and a pine

Is that what you would want?

2. VoG's formula would produce a result in another column. Is that okay or were you looking to actually change the values that are in column B? To do that would require vba code.


Hi Peter

I see where you are coming from but my data all looks sound - yes the A1 text would indeed be a complete string, and another column is in fact best for me in this case.

Thanks very much
Kevin
 
Upvote 0
So, if you did want to cover the possibility of any cases like the one I gave, and still deal with the simpler ones, it isn't much harder:

=TRIM(SUBSTITUTE(" "&B1&" "," "&A1&" "," "))
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,875
Members
452,949
Latest member
Dupuhini

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