Add up a range only if divisible by x

CafeRoaster

New Member
Joined
Oct 31, 2022
Messages
5
Platform
  1. MacOS
Hello there. I run a coffee roastery, and we offer several sizes. I'm attempting to build a sheet that tells our packaging team how many 2-lb bags and how many 5-lb bags to prepare. Customers can order by the pound. We have a 2-lb bag that all weights below or equal to 2-lbs go into, and a 5-lb bag that all weights below or equal to 5-lbs go into.

For instance, if someone order 1 lb, that goes into a 2-lb bag. If someone orders 3 lbs, that goes into a 5-lb bag.

These amounts get filled into Column B as however much they ordered. Column A contains the customer account name and the word BULK.

I want to be able to distinguish between what goes into a 2-lb bag and what goes into a 5-lb bag.

Currently, I have this, but it isn't doing what I need it to do.
Excel Formula:
=mod(SUMIFS(B11:B82,$A$11:$A$82,"*BULK*"),5)

In order for this to work, I cannot simply use "<=2" and ">2", because if someone orders 12 lbs, for instance, that's 2x 5-lb bags and one 2-lb bag.

Cell B5 is doing the math for finding <=2, and Cell B6 is doing math for >2.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Assuming you have columns - Weight, 5 lb Bags, 2 lb Bags.

5 lb Bags = INT(Weight/5)
2 lb Bags = ROUNDUP( (Weight - (5 lb Bags * 5))/2, 0 )

Here's what I came up with:

=INT( [@Weight] /5)=ROUNDUP( ([@Weight]-([@[5 Lb Bags]]*5))/2, 0 )
OrderWeight5 Lb Bags2 Lb Bags
11422
2101
3510
41322
51121
6402
7711
8812
9101
10302
11611
12101
131322
14201
15510
161020
17912
181731
191932
20611
 
Upvote 0
Here's another take on it:

Book1
ABCD
1OrderWeight5 Lb Bags2 Lb Bags
211430
32101
43510
541330
651121
76410
87711
98820
109101
1110310
1211611
1312101
14131330
1514201
1615510
17161020
1817920
19181731
20191940
2120611
Sheet1
Cell Formulas
RangeFormula
C2:C21C2=INT(B2/5)+(MOD(B2,5)>2)
D2:D21D2=(B2>C2*5)+0


This will result in using fewer total bags, but more of the 5-pound bags. Compare orders 1 and 4 for example to see the difference.
 
Upvote 0
Book1
ABCD
1OrderWeight5 Lb Bags2 Lb Bags
211430
32101
43510
541330
651121
76410
87711
98820
109101
1110310
1211611
1312101
14131330
1514201
1615510
17161020
1817920
19181731
20191940
2120611
22
23319
24319
Sheet1
Cell Formulas
RangeFormula
C2:C21C2=ROUND(B2/5,0)
D2:D21D2=(B2>C2*5)+0
C23:D23C23=SUM(C2:C21)
C24C24=SUMPRODUCT(ROUND(B2:B21/5,0))
D24D24=SUMPRODUCT((MOD($B$2:$B$21,5)<3)*(MOD($B$2:$B$21,5)>0))
 
Upvote 0
Solution
Hmm. These are great solutions, but I can't seem to get them to work with my sheet. As it is now, I cannot add a column to do the math for each order. I need to be able to do it for an array (specifically, B11:B82), all in one cell.
 
Upvote 0
Here's a test sheet of the range I'm working with.
 
Upvote 0
I've decided to go with the solution by @Phuoc. I'll create two row next to each column that represents a type of coffee. Those rows will do the math, and I'll hide them so as to not clutter the sheet.

Thank you all!
 
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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