Searching for values in a range, matching to a cell - FAIL

teston

New Member
Joined
Feb 5, 2019
Messages
6
Hello,

I have two sheets:

Sheet 1 contains data I need to process:

Book1
ABC
1SizeFruit
2big apples
3small oranges
4medium pears
5huge watermelons
6big apple
7small orange
8medium pear
9huge watermelon
Sheet1


Sheet 2 is a database of values:

Book1
AB
1SizeFruit
2bigapple
3smallorange
4mediumpear
5hugewatermelon
Sheet2


I need to populate empty cells in Sheet 1 with matching values from Sheet 2 so that final result looks like this:

Book1
ABC
1SizeFruit
2big applesbigapple
3small orangessmallorange
4medium pearsmediumpear
5huge watermelonshugewatermelon
6big applebigapple
7small orangesmallorange
8medium pearmediumpear
9huge watermelonhugewatermelon
Sheet1


I have tried this formula:

Excel Formula:
=IF(ISNUMBER(SEARCH(Sheet2!A:A, $A2)),Sheet2!A:A,"")

but it only works for cells with plural values, not singular:

Book1
ABC
1SizeFruit
2big applesbigapple
3small orangessmallorange
4medium pearsmediumpear
5huge watermelonshugewatermelon
6big apple00
7small orange00
8medium pear00
9huge watermelon00
Sheet1
Cell Formulas
RangeFormula
B2:C9B2=IF(ISNUMBER(SEARCH(Sheet2!A:A, $A2)),Sheet2!A:A,"")


What would be the best way to achieve this? (Please note that it's important to use the partial match - apple should match apple & apples).

Thanks!
 

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,

If your Sheet1 Size is Always on Sheet2, you can simply use E2 formula for Size, otherwise, if you have values like A11, then use B2 formula copied across for Both Size and Fruit:

Note: I highly recommend Not using Entire Column references (i.e. A:A, B:B, etc.), you'll definitely notice a performance degradation, just use a range you know is more than sufficient (i.e. A2:A20000).

Book1
ABCDE
1SizeFruitSize
2big applesbigapplebig
3small orangessmallorangesmall
4medium pearsmediumpearmedium
5huge watermelonshugewatermelonhuge
6big applebigapplebig
7small orangesmallorangesmall
8medium pearmediumpearmedium
9huge watermelonhugewatermelonhuge
10medium pineapplemedium medium
11tiny apples apple
Sheet1
Cell Formulas
RangeFormula
B2:C11B2=IFERROR(LOOKUP(2,1/(SEARCH(" "&Sheet2!A$2:A$200," "&$A2)*(Sheet2!A$2:A$200<>"")),Sheet2!A$2:A$200),"")
E2:E10E2=LEFT(A2,FIND(" ",A2)-1)


Book1
AB
1SizeFruit
2bigapple
3smallorange
4mediumpear
5hugewatermelon
Sheet2
 
Upvote 0
Upvote 0
@BSALV , just a note, your formula will pick up "apple" for "pineapple" in my sample A10, and error out if there are Blanks in Sheet2 range.
 
Last edited:
Upvote 0
Thanks jtakw! You have saved my life :)

Is it possible to make it pick the first matching value from Sheet2 (assuming it looks up top to bottom)?

Currently it works like this:

Book1
ABCD
1SizeFruitDefinition
211 huge and very big appleshugeapplevery
3their big and very huge applehugeapplevery
Sheet1
Cell Formulas
RangeFormula
B2:D3B2=IFERROR(LOOKUP(2,1/(SEARCH(" "&Sheet2!A$2:A$200," "&$A2)*(Sheet2!A$2:A$200<>"")),Sheet2!A$2:A$200),"")


with Sheet2 values being in this sequence:

Book1
AB
1SizeFruit
2bigapple
3smallorange
4mediumpear
5hugewatermelon
6berry
Sheet2


So that final result looks like this:

Book1
AB
1Size
211 huge and very big applesbig
3their big and very huge applebig
Sheet1


Thank you so much!
 
Upvote 0
Well, there's a problem here, you have Both "huge" and "big" in the same cell, what's the logic, and how will Excel know which is the correct outcome?

So, if the logic is basically an Exact match (less the singular/plural part), then we concatenate the 2 columns in Sheet2 with a wild card, like this:

Book1.xlsx
ABC
1SizeFruit
2big applesbigapple
3small orangessmallorange
4medium pearsmediumpear
5huge watermelonshugewatermelon
6big applebigapple
7small orangesmallorange
8medium pearmediumpear
9huge watermelonhugewatermelon
10medium pineapple  
11tiny apples  
1211 huge and very big applesbigapple
13their big and very huge applebigapple
Sheet1
Cell Formulas
RangeFormula
B2:C13B2=IFERROR(LOOKUP(2,1/(SEARCH(" "&Sheet2!$A$2:$A$200&"*"&Sheet2!$B$2:$B$200," "&$A2)*(Sheet2!A$2:A$200<>"")),Sheet2!A$2:A$200),"")


Book1.xlsx
AB
1SizeFruit
2bigapple
3smallorange
4mediumpear
5hugewatermelon
Sheet2
 
Upvote 0
Teston.xlsx
with 2 named ranges

Again my warning, this are very intense formulas.
they 'll slow down the performance of your worksheet if there are too much of them or the size of the table in sheet2 is big.
It's perhaps better to let them do their job and afterwards replace them with their value !

Map1
DEFGHIJ
4
5
6SizeFruitdefinition
7bigapplex
8smallorangey
9mediumpearz
10hugewatermelona
11
12
13Offset_Tbl=RIJ(TBL_Database[[#Kopteksten];[Size]])
14TBL_C1=TBL_Database[Size]
15
16
sheet2


Map1
ABC
1SizeFruit
211 huge and very big applesbigapple
3their big and very huge applebigapple
4big applesbigapple
5small orangessmallorange
6medium pearsmediumpear
7huge watermelonshugewatermelon
8big applebigapple
9small orangesmallorange
10medium pearmediumpear
11huge watermelonhugewatermelon
12a_big_apple, pineapple, britney spears, orange?orange
13big applesbigapple
14small orangessmallorange
15medium pearsmediumpear
16huge watermelonshugewatermelon
17big applebigapple
18small orangesmallorange
19medium pearmediumpear
20huge watermelonhugewatermelon
Blad1
Cell Formulas
RangeFormula
B2:C20B2=IFERROR(INDEX(OFFSET(TBL_C1,,COLUMN()-2,,),MIN(IF(ISNUMBER(SEARCH(" " &OFFSET(TBL_C1,,COLUMN()-2,,)," " &$A2)),ROW(TBL_C1),9E+99))-Offset_Tbl),"?")
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

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