Look up using index/match not working with duplicate values

grantjw

New Member
Joined
Dec 17, 2012
Messages
12
[TABLE="width: 410"]
<colgroup><col span="4"><col><col></colgroup><tbody></tbody>[/TABLE]
[TABLE="width: 474"]
<colgroup><col span="5"><col><col></colgroup><tbody></tbody>[/TABLE]
[TABLE="width: 484"]
<colgroup><col span="2"><col><col span="2"><col><col></colgroup><tbody>[TR]
[TD]1/A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD="colspan: 2"]DATA TABLE Sheet1[/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 2"]LOOKUP TABLE Sheet 2[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Price[/TD]
[TD]Qty[/TD]
[TD][/TD]
[TD][/TD]
[TD]Desired Qty[/TD]
[TD]Price[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]1.08[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]50[/TD]
[TD]1.05[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]1.05[/TD]
[TD]50[/TD]
[TD][/TD]
[TD][/TD]
[TD]100[/TD]
[TD]1.02[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]1.02[/TD]
[TD]100[/TD]
[TD][/TD]
[TD][/TD]
[TD]100[/TD]
[TD]1.02[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]0.99[/TD]
[TD]100[/TD]
[TD][/TD]
[TD][/TD]
[TD]100[/TD]
[TD]1.02[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]0.96[/TD]
[TD]100[/TD]
[TD][/TD]
[TD][/TD]
[TD]75[/TD]
[TD]0.93[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]0.93[/TD]
[TD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/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]36[/TD]
[TD]0.15[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]37[/TD]
[TD]0.12
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Data table on sheet 1
Data in column C can be changed and be placed or removed on any rows

Look up table, used by users on sheet 2
Desired Qty in col F
is used with the following index/match function =INDEX($B$5:$B$37,MATCH(F5,$C$5:$C$37,0)) in Col G
Duplicate values are not looked up properly.

Both tables are on same sheet for illustrative purposes.

Please Help!

Thanks for your time and effort :)
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Maybe:


Book1
ABCDEFG
1PriceQtyDesired QtyPrice
21.08501.05
31.05501001.02
41.021001000.99
50.991001000.96
60.96100750.93
70.9375750.9
80.975500.87
90.8750500.84
100.8450250.81
110.8125
120.7825
130.7510
140.72
150.69
160.66
170.63
180.6
190.57
200.54
210.51
220.48
230.45
240.42
250.39
260.36
270.33
280.3
290.27
300.24
310.21
320.18
330.15
340.12
Sheet1
Cell Formulas
RangeFormula
G2{=INDEX($A$2:$A$34,SMALL(IF(OR($B$2:$B$34=F2,$B$2:$B$34<>""),ROW($A$2:$A$34)-ROW($A$2)+2),ROW($F2:F2)-ROW($F$2)+1))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Thanks for you reply. It is greatly appreciated. It works if the desired quantity stays the same. If the desired quantity changes and I drop the qty 50 from the data table and 50 from look up table, the qty/price pair should be 100 & 1.02. I think I need to change something in the row reference in your solution but an not sure what to change.
 
Upvote 0
I can't install the HTML plugin, my PC is locked down by our IT folks. I will do my best to provide clarity.

Column F, desired quantity, is linked to the Data table, Column B. Col. B can updated to add and remove values. First example started row 2 with 50 but can change. in the example below it starts at row 5 with 100. Col B can contain values from rows 2 to 34.

Col. F is linked to Col B. Using formulas in Col. F always display the first qty from Col. B in F2. So Col. F can grow or shrink depending on values in Col. B.

So, as Col. F values are updated (from Col. B) I need to display the the correct matching price in Col G (from Col A).

Your proposed solution did not look up the correct value when the desired quantity value in Col B moved its position. This is what It looked liked.

[TABLE="width: 474"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[/TR]
[TR]
[TD]Price[/TD]
[TD]Qty[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Desired Qty[/TD]
[TD]Price[/TD]
[/TR]
[TR]
[TD]1.08[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]100[/TD]
[TD]1.05[/TD]
[/TR]
[TR]
[TD]1.05[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]100[/TD]
[TD]1.02[/TD]
[/TR]
[TR]
[TD]1.02[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]75[/TD]
[TD]0.99[/TD]
[/TR]
[TR]
[TD]0.99[/TD]
[TD]100[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]75[/TD]
[TD]0.96[/TD]
[/TR]
[TR]
[TD]0.96[/TD]
[TD]100[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]50[/TD]
[TD]0.93[/TD]
[/TR]
[TR]
[TD]0.93[/TD]
[TD]75[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]50[/TD]
[TD]0.9[/TD]
[/TR]
[TR]
[TD]0.9[/TD]
[TD]75[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]25[/TD]
[TD]0.87[/TD]
[/TR]
[TR]
[TD]0.87[/TD]
[TD]50[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]25[/TD]
[TD]0.84[/TD]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12[/TD]
[/TR]
[TR]
[TD]0.12[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Thanks for your time and consideration.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

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