Compare range 1 with range 2 and past matched value in range 3

shafiq2

New Member
Joined
Jun 19, 2014
Messages
42
Hi,

I am looking for excel function or VBA to compare two different ranges and if any value from range 1 matches with value in range 2 then copy the value from range 2 to range 3, if no value matched then the value in range 3 should be others

As shown in the table below
Sample of data
Subject MatchedItem
Do you like apple



Apple
sugar is not good for health Sugar
Is lemon color yellow? lemon
Too much salt is not good salt
where is my car other
Result
Subject MatchedItem
Do you like apple



AppleLemon
sugar is not good for healthSugar Sugar
Is lemon color yellow?LemonApple
Too much salt is not goodSaltsalt
where is my car Otherother

<colgroup><col style="width: 134pt; mso-width-source: userset; mso-width-alt: 6546;" width="179"> <col style="width: 72pt; mso-width-source: userset; mso-width-alt: 3510;" width="96"> <col style="width: 48pt;" width="64"> <tbody>
</tbody>


<tbody>
</tbody><colgroup><col><col><col></colgroup>
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi

in C2:C5 Lemon-Sugar-Apple-Salt, a possible formula to extract substrings form A2:


Code:
=IFERROR(INDEX($C$2:$C$5,MATCH(1,INDEX(SEARCH("* "&$C$2:$C$5&" *",A2&" ",0),0)),"Other")

Hope it helps
 
Upvote 0
Hi,

Thanks for the formula, I have checked the formula, it brings everything as "other".

Regards,
 
Upvote 0
Hi,

thanks for feedback.


Code:
=IF(A2<>"",IFERROR(INDEX($C$2:$C$5;MATCH(1,INDEX(SEARCH("*"&$C$2:$C$5&"*",A2),0),0)),"Other"),"")

A small example here:


http://wikisend.com/download/148246/cercasottostringhe.xlsx


Regards

<colgroup><col width="64"></colgroup><tbody>
</tbody>
 
Upvote 0
Hi,

thanks for feedback.


Code:
=IF(A2<>"",IFERROR(INDEX($C$2:$C$5;MATCH(1,INDEX(SEARCH("*"&$C$2:$C$5&"*",A2),0),0)),"Other"),"")

A small example here:


http://wikisend.com/download/148246/cercasottostringhe.xlsx


Regards

<tbody>
</tbody>

Thank you for the formula, it works perfectly.

Best Regards,
 
Upvote 0

Forum statistics

Threads
1,216,523
Messages
6,131,151
Members
449,626
Latest member
Stormythebandit

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