Math Help!

tobermory

New Member
Joined
Jun 4, 2012
Messages
46
Hi there,

Please take a look at my sample spreadsheet I've imported to google. I do use Excel 2016, I've just imported for you guys to view.

https://docs.google.com/spreadsheets/d/1C2frEj0Lmzghy5nyDJxOgD57hjeORUEf5V183jCpMKA/edit?usp=sharing

I need a formula/code that calculates the following questions...

H2 - How many boxes do I need to collect to fulfill collecting 7 apples (F2) using the LOWEST qtys first? (i.e. 1+2+2+2 = 7 - 4 Boxes)

I2 - How many boxes do I need to collect to fulfill collecting 7 apples (F2) using the HIGHEST qtys first? (i.e. 5+5 = 10 - 2 Boxes)

and then so forth for the following fruits/qtys listed...

Thank you so much for any help in advance!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hello tobermory,

Assuming you are using Excel and also assuming the fruits will be grouped and listed in order as per your example then try this array formula in H2

=IF(F2>SUMIF(B:B,E2,C:C),"Too high",IFERROR(MATCH(F2-1,SUMIF(OFFSET(B$1,MATCH(E2,B:B,0)-1,0,ROW(INDIRECT("1:"&F2))),E2,INDEX(C:C,MATCH(E2,B:B,0)))),0)+1)

and this one in I2

=IF(F2>SUMIF(B:B,E2,C:C),"Too high",IFERROR(MATCH(F2-1,SUMIF(OFFSET(B$1,MATCH(E2,B:B)-1,0,-ROW(INDIRECT("1:"&F2))),E2,OFFSET(C$1,MATCH(E2,B:B)-1,0,-ROW(INDIRECT("1:"&F2))))),0)+1)

both confirmed with CTRL+SHIFT+ENTER and copied down

I get the same results as you except for I3 where I get 3 for Banana using highest (5+5+4)
 
Upvote 0
This may be too much to ask but...

Would there be any way to do it if the fruits WASN'T grouped and the qtys not in order?

Thanks sincerely once again.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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