Remove a string based on other column value

andranos

New Member
Joined
May 28, 2014
Messages
9
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
Thanks in advance guys
 

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
Joined
Jul 4, 2004
Messages
7,484
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
Joined
Apr 18, 2011
Messages
37,867
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Try:

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

<colgroup><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

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

<thead>
</thead><tbody>
</tbody>

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

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

andranos

New Member
Joined
May 28, 2014
Messages
9
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
Joined
Jul 4, 2004
Messages
7,484
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)
 
Master Excel Bundle

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.

Forum statistics

Threads
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.
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
Top