I am looking for a function that will give me the Item that meets the criteria Class=A, Location >= Start, Location <= End.
This can be achieved via =index($A$2:$A$10;small(if((A=$B$2:$B$10)*(Location>=$C$2:$C$10)*(Location<=$D$2:$D$10);Row($A$2:$A$10)-1;"");1))
However, if there are multiple matches for this formula I would like to order them with (Location-Start)*(End-Location) as criteria going from highest to lowest. If at all possible I would like to do this without extra columns added.
thank you very much for your reply. I changed the numbers slightly.
The desired output would be:
Item2
Item3
Item1
I added the calculations for clarification, but these should not appear in the final version. The output is ordered by (Location-Start)*(End-Location).
I looked at your formula. I see that you cascaded the if statement and you added the countif-function. I don't quite understand what the countif function does here. Please explain.
I think we're getting closer to your ultimate goal, but I'm a bit confused by your example. Item2 in the table on the left has Start and End of 40/150, but in the response table on the right it has 30/80?
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}. Note: Do not try and enter the {} manually yourself
<tbody>
</tbody>
The main formula is in G5. The H and I formulas just return the matching locations, and J is just the product. You can remove any of those.
The formula mainly finds the matching rows, calculates C*D, and finds the largest. It then uses MATCH to find the location of the largest value within the matching rows again. The COUNTIF looks at the rows above the formula (so G5 looks at G4, G6 looks at G4:G5, G7 looks at G4:G6, etc.) to see if the item has already been found. If it has, it's excluded from further consideration, meaning that the next row down will find the next highest value, or the highest remaining after the highest is excluded.
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.