Using lookup to find values (1 or more) based on criteria, greater than, less than, etc.

prodigy157

New Member
Joined
May 30, 2018
Messages
3
See my example table below.

order #costred heightyellow heightorange heightv1 weightv2 weightv3 weight
Order 20 2,160 404040332339274800
Order 22 2,406 454550370243755347
Order 23 2,395 454550368543555322
Order 25 2,709 454547416849256020
Order 27 2,923 454550449753156496
Order 30 3,212 505050494260607138
Order 31 3,376 404045519463707502
Order 35 3,672 595959564972008160
Order 38 4,044 505055641982538987

<tbody>
</tbody>


Two things:

1. I want to look up the order with the highest cost, as long as certain height and weight requirements are met. For example, what's the most expensive order with a yellow height of no more than 45 and a v2 weight no more than 5000. The answer is order 25, but how do i build a formula to show this.

2. going back to the example above, in addition to being able to list the one with the highest cost, I want to be able to lookup ALL orders that meet the criteria, and have those go into a drop down list, or some other way of showing multitple lookup answers in a single cell. In this case, the correct answers are order 20, 22, 23 and 25.

I've searched the internet a lot and played around with VLOOKUP, MIN, MAX, array formulas, etc., but I'm just going in circles, can't figure it out. Thanks in advance for the help!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Not sure how you could do the second question with a formula. The first should be possible, however it would be quite complex, and not easy to amend if your search criteria change.

Have you considered using filters - this would allow you to set criteria you want for each column and see which orders remain?

Alternatively use a macro with a form to allow input of criteria. The macro could loop through the records, concatenating the order numbers of matching records into a single variable that could be written into a single cell, if that's what you need?
 
Upvote 0

Book1
ABCDEFGHIJ
1order #costred heightyellow heightorange heightv1 weightv2 weightv3 weightheight
2Order 202,16040404033233927480045
3Order 222,406454550370243755347v2
4Order 232,3954545503685435553225000
5Order 252,709454547416849256020Order 20
6Order 272,923454550449753156496Order 22
7Order 303,212505050494260607138Order 23
8Order 313,376404045519463707502Order 25
9Order 353,672595959564972008160
10Order 384,044505055641982538987
Sheet1


In J5 control+shift+enter, not just enter, and copy down:

=IFERROR(INDEX($A$2:$A$10,SMALL(IF($D$2:$D$10<=J$2,IF($G$2:$G$10<=J$4,ROW($A$2:$A$10)-ROW($A$2)+1)),ROWS(J$5:J5))),"")
 
Upvote 0
ABCDEFGHIJ
1order #costred heightyellow heightorange heightv1 weightv2 weightv3 weightheight
2Order 202,16040404033233927480045
3Order 222,406454550370243755347v2
4Order 232,3954545503685435553225000
5Order 252,709454547416849256020Order 20
6Order 272,923454550449753156496Order 22
7Order 303,212505050494260607138Order 23
8Order 313,376404045519463707502Order 25
9Order 353,672595959564972008160
10Order 384,044505055641982538987

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1



In J5 control+shift+enter, not just enter, and copy down:

=IFERROR(INDEX($A$2:$A$10,SMALL(IF($D$2:$D$10<=J$2,IF($G$2:$G$10<=J$4,ROW($A$2:$A$10)-ROW($A$2)+1)),ROWS(J$5:J5))),"")

This is FANTASTIC, thank you. Now my only remaining question is - how would this formula be altered to allow the choice between red, yellow and orange height, as well as v1, v2 and v3 weight. Your formula has it hard coded for column's D and G, however I'm going to have two separate cells that, in this scenario for example, would say "yellow height" and "v2 weight." How can I have the formula look at these cells to see the selected option, then go search/lookup in the table to see which column to use, based on the header of that column.

Again, thanks so much, I never would have gotten this far.
 
Upvote 0
This is FANTASTIC, thank you. Now my only remaining question is - how would this formula be altered to allow the choice between red, yellow and orange height, as well as v1, v2 and v3 weight. Your formula has it hard coded for column's D and G, however I'm going to have two separate cells that, in this scenario for example, would say "yellow height" and "v2 weight." How can I have the formula look at these cells to see the selected option, then go search/lookup in the table to see which column to use, based on the header of that column.

Again, thanks so much, I never would have gotten this far.


Book1
ABCDEFGHIJ
1order #costred heightyellow heightorange heightv1 weightv2 weightv3 weightyellow height
2Order 202,16040404033233927480045
3Order 222,406454550370243755347v2 weight
4Order 232,3954545503685435553225000
5Order 252,709454547416849256020Order 20
6Order 272,923454550449753156496Order 22
7Order 303,212505050494260607138Order 23
8Order 313,376404045519463707502Order 25
9Order 353,672595959564972008160
10Order 384,044505055641982538987
Sheet1 (2)


In J5 control+shift+enter, not just enter, and copy down:

=IFERROR(INDEX($A$2:$A$10,SMALL(IF(INDEX($C$2:$H$10,0,MATCH(J$1,$C$1:$H$1,0))<=J$2,IF(INDEX($C$2:$H$10,0,MATCH(J$3,$C$1:$H$1,0))<=J$4,ROW($A$2:$A$10)-ROW($A$2)+1)),ROWS(J$5:J5))),"")
 
Upvote 0

Forum statistics

Threads
1,215,523
Messages
6,125,318
Members
449,218
Latest member
Excel Master

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