# Remove a string based on other column value

#### andranos

##### New Member
Hey guys,

Need some help with deleting a value using other cell value as a reference
For example:

Column A, Column B, Result
Random1, I Love Random1 Apple, I Love Apple
Apple, Apple is Sweet, is Sweet

More or less like that

### Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

#### jim may

##### Well-known Member
Try:

Excel 2012
ABC
1Column AColumn BResult
2Random1I Love Random1 AppleI Love Apple
3AppleApple is Sweetis Sweet
Sheet1
Cell Formulas
RangeFormula
C2=SUBSTITUTE(B2,A2,"")

#### Rick Rothstein

##### MrExcel MVP
Try:

Excel 2012
ABC
1Column A Column B Result
2Random1 I Love Random1 Apple I Love Apple
3Apple Apple is Sweet is Sweet

</tbody>
Sheet1

Worksheet Formulas
CellFormula
C2=SUBSTITUTE(B2,A2,"")

</tbody>

<tbody>
</tbody>
Maybe wrapping a TRIM function around that would be useful...

=TRIM(SUBSTITUTE(B2,A2,""))

#### andranos

##### New Member
Try:

Excel 2012
ABC
1Column A Column B Result
2Random1 I Love Random1 Apple I Love Apple
3Apple Apple is Sweet is Sweet

<tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
C2=SUBSTITUTE(B2,A2,"")

<tbody>
</tbody>

<tbody>
</tbody>

Works like a charm
There's another problem though
Here's an example

Excel 2012
ABC
1Column A Column BResult
2LoveI Love Apple LoveI Love Apple
3AppleApple is Sweet AppleApple is Sweet

<tbody>
</tbody>

<table cellpadding="2.5px" rules="all" verdana,="" arial,="" tahoma,="" calibri,="" geneva,="" sans-serif;="" border:="" 1px="" solid="" rgb(187,="" 187,="" 187);="" border-collapse:="" collapse;"="" style="width: " width=""><colgroup><col><col><col><col></colgroup><thead></thead><tbody></tbody></table>

I need to remove the duplicated keyword based on column A value and the latest one will be deleted
And the condition only applies if the keyword from column A is duplicate in column B. If it's not, leave it as it is
Is that possible?

Cheers

Last edited:

#### jim may

##### Well-known Member
Try:

Note addition of the "2" as an additional argument at the end. This instructs excel to "START" the search AFTER finding number 1 (the first instance). Hope that helps. Jim

Excel 2012
ABC
1Column AColumn BResult
2LoveI Love Apple LoveI Love Apple
3AppleApple is Sweet AppleApple is Sweet
4SourApple is Sweet AppleApple is Sweet Apple
Sheet1
Cell Formulas
RangeFormula
C2=SUBSTITUTE(B2,A2,"",2)

Replies
13
Views
541
Replies
4
Views
372
Replies
5
Views
157
Replies
3
Views
153
Replies
1
Views
137

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,163,777
Messages
5,833,643
Members
430,221
Latest member
jmmccormick

### 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.

### Which adblocker are you using?

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

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