Candies in the jar

Robert Mika

MrExcel MVP
Joined
Jun 29, 2009
Messages
7,256
Hi All,
I have 3 jars:

The capacity of the first is 20(small) , of the second 48(medium) and the last one 300(large).

How can I split 301, 349 and 369 candies into those jars?
In the first case the formula shoudl say:
1 small and 1 large,
in the second case 1 small, 1 medium, 1 large.
in the last case 2 large.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
At what level of candies do you switch from multiple medium jars to one large jar?
 
Upvote 0
Bit confused, you say you have 3 jars (so assume they're of size large, medium and small), but when you have 369 candies, you say they can only fit into 2 large jars. Do you have an unlimited quantity of jars and respective sizes? If so, why not just fit everything into a variable quantity of large sized jars, using the MOD function to calculate how many are required?
 
Upvote 0
Correct me if I'm wrong, but I believe the goal is to minimize "empty space" in the jars. ie. while 368 would fit in two large jars, it would fit in one of each with zero "empty space". Is this along the right lines?
 
Upvote 0
368 would, but he says he has 369 candies, so eat 1 candy and then you can maximise space.. otherwise if unlimited number of jars, then 2 large jars would be the solution.
 
Upvote 0
Hi All,
Thanks for input

Sorry for a confusion.
There will be no 3 jars but 3 diffrent capacity of jars.

The cut off for medium is 144 which is 3.
From that point till 300 it will be 1 large.
Then from 301 - 1 small 1 large
329 - 1 large ,1 medium
 
Last edited:
Upvote 0
Assuming the number of candies is in A3, For large jars in A5, try: =INT(A3/300)
In B5 for med jars try: =INT((A3-(A5*300))/48)
And in C5 for small jars try: =ROUNDUP((A3-(A5*300)-(B5*48))/20,0)
 
Upvote 0
I have assumed that the number of candies is in A3, the formula for large jars is in A5, for medium jars in B5 and the formula for small jars is in C5.

I may have misunderstood your requirements because my formulas will give for 301 - 1 large and one small; for 349 1 large 1 medium and 1 small. However for 369 it gives 1 large, 1 medium and 2 small.
 
Upvote 0
My automatic calcs also give 1 large, 1 medium and 2 small ... what rules make it go to 2 large exactly?
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,319
Members
452,905
Latest member
deadwings

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