Remove a string based on other column value

andranos

New Member
Joined
May 28, 2014
Messages
8
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
 

Some videos you may like

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,480
Try:

<b>Excel 2012</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB"><colgroup><col width="25px" style="background-color: #DAE7F5" /><col /><col /><col /></colgroup><thead><tr style=" background-color: #DAE7F5;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="color: #574123;;">Column A </td><td style=";"> Column B </td><td style=";"> Result</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="color: #574123;;">Random1</td><td style=";"> I Love Random1 Apple</td><td style=";"> I Love  Apple</td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="color: #574123;;">Apple</td><td style=";"> Apple is Sweet</td><td style=";">  is Sweet</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #BBB;border-top:none;text-align: center;background-color: #DAE7F5;color: #161120">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #BBB"><thead><tr style=" background-color: #DAE7F5;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">C2</th><td style="text-align:left">=SUBSTITUTE(<font color="Blue">B2,A2,""</font>)</td></tr></tbody></table></td></tr></table><br />
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,680
Office Version
  1. 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
8
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,480
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

<b>Excel 2012</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB"><colgroup><col width="25px" style="background-color: #DAE7F5" /><col /><col /><col /></colgroup><thead><tr style=" background-color: #DAE7F5;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="color: #574123;background-color: #FFFFFF;;">Column A</td><td style="color: #574123;background-color: #FFFFFF;;">Column B</td><td style="color: #574123;background-color: #FFFFFF;;">Result</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="color: #574123;background-color: #FFFFFF;;">Love</td><td style="color: #574123;background-color: #FFFFFF;;">I Love Apple Love</td><td style=";">I Love Apple </td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="color: #574123;background-color: #FFFFFF;;">Apple</td><td style="color: #574123;background-color: #FFFFFF;;">Apple is Sweet Apple</td><td style=";">Apple is Sweet </td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="color: #574123;background-color: #FFFFFF;;">Sour</td><td style="color: #574123;background-color: #FFFFFF;;">Apple is Sweet Apple</td><td style=";">Apple is Sweet Apple</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #BBB;border-top:none;text-align: center;background-color: #DAE7F5;color: #161120">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #BBB"><thead><tr style=" background-color: #DAE7F5;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">C2</th><td style="text-align:left">=SUBSTITUTE(<font color="Blue">B2,A2,"",2</font>)</td></tr></tbody></table></td></tr></table><br />
 

Watch MrExcel Video

Forum statistics

Threads
1,122,554
Messages
5,596,811
Members
414,104
Latest member
imamalidadashzada

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