Divide cost across variable quantity

berger_d

New Member
Joined
Apr 29, 2020
Messages
13
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm trying to create a cost spreadsheet "tool". I've found some other solutions, but the Qty was always fixed and that is not the case for me. For example if an order has a bundle of 198 widgets that is sold for $72.40. I need to list the cost for each widget and if I simply divide the cost of $72.40 by 198, I get $0.37 each due to rounding. The preferred outcome is to have Qty 86 at $0.36 and Qty 112 at $0.37. Obviously if I didn't need to do this on a large number of items I'd just do it manually, but this is a regular issue I'm trying to solve with a formula.

I'd like to be able to enter the Cost in A1 and the Qty in A2 with a formula as needed. The widget cost and quantity are variable in each instance that I need this for. Ideally I'd like only two individual widget costs, but if a third would be needed to avoid rounding issues, that too would be acceptable.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
How about this?

Dashboard and Even Distribution of Items in Set.xlsm
ABCDEF
172.4
2198Qty:86112
3Amt:0.360.37
4
5Total: 30.9641.4472.4
Sheet1
Cell Formulas
RangeFormula
D2:E3D2=LET(amt,A1,qty,A2,seq,SEQUENCE(qty),lb,TRUNC(amt/qty,2),ub,lb+0.01,lc,seq*lb,ic,ROUND((amt-lc)/ub,2),tbl,CHOOSE({1,2,3,4},seq,lc,ic,MOD(ic,INT(ic))=0),flt,FILTER(tbl,INDEX(tbl,,4)),mx,INDEX(flt,,1)*INDEX(flt,,3),m,MAX(mx),nt,CHOOSE({1,1,1,2},flt,mx),x,INDEX(FILTER(nt,INDEX(nt,,4)=m),,{1,3}),IFERROR(INDEX(x,SEQUENCE(ROWS(x)+1),{1,2}),CHOOSE({1,2},lb,ub)))
D5:E5D5=D2*D3
F5F5=SUM(D5:E5)
Dynamic array formulas.
 
Upvote 0
How about this?

Dashboard and Even Distribution of Items in Set.xlsm
ABCDEF
172.4
2198Qty:86112
3Amt:0.360.37
4
5Total: 30.9641.4472.4
Sheet1
Cell Formulas
RangeFormula
D2:E3D2=LET(amt,A1,qty,A2,seq,SEQUENCE(qty),lb,TRUNC(amt/qty,2),ub,lb+0.01,lc,seq*lb,ic,ROUND((amt-lc)/ub,2),tbl,CHOOSE({1,2,3,4},seq,lc,ic,MOD(ic,INT(ic))=0),flt,FILTER(tbl,INDEX(tbl,,4)),mx,INDEX(flt,,1)*INDEX(flt,,3),m,MAX(mx),nt,CHOOSE({1,1,1,2},flt,mx),x,INDEX(FILTER(nt,INDEX(nt,,4)=m),,{1,3}),IFERROR(INDEX(x,SEQUENCE(ROWS(x)+1),{1,2}),CHOOSE({1,2},lb,ub)))
D5:E5D5=D2*D3
F5F5=SUM(D5:E5)
Dynamic array formulas.

WOW This looks exactly like what I need!!!! And in about 15 minutes after I posted the request. Very very grateful for your help.

I’ll reply back after I’ve done some testing.
 
Upvote 0
How about this?

Dashboard and Even Distribution of Items in Set.xlsm
ABCDEF
172.4
2198Qty:86112
3Amt:0.360.37
4
5Total: 30.9641.4472.4
Sheet1
Cell Formulas
RangeFormula
D2:E3D2=LET(amt,A1,qty,A2,seq,SEQUENCE(qty),lb,TRUNC(amt/qty,2),ub,lb+0.01,lc,seq*lb,ic,ROUND((amt-lc)/ub,2),tbl,CHOOSE({1,2,3,4},seq,lc,ic,MOD(ic,INT(ic))=0),flt,FILTER(tbl,INDEX(tbl,,4)),mx,INDEX(flt,,1)*INDEX(flt,,3),m,MAX(mx),nt,CHOOSE({1,1,1,2},flt,mx),x,INDEX(FILTER(nt,INDEX(nt,,4)=m),,{1,3}),IFERROR(INDEX(x,SEQUENCE(ROWS(x)+1),{1,2}),CHOOSE({1,2},lb,ub)))
D5:E5D5=D2*D3
F5F5=SUM(D5:E5)
Dynamic array formulas.

Hi @lrobbo314

Thanks again for the very quick reply yesterday. I do not have the XL2BB add in, but don't believe I need it to copy/paste your mini sheet into Excel. When I copy/paste into Excel (365) I'm getting a #NAME? error in D2. Do I need to do anything else to utilize the formula you provided? Sorry, I'm sure this is user error on my part, I've searched the forum but not seeing a solution to this.

1621258802450.png
 
Upvote 0
How about
+Fluff 1.xlsm
ABCDE
172.40
219811286
30.370.36
4
541.4430.9672.40
Lists
Cell Formulas
RangeFormula
C2C2=(A1-ROUNDDOWN(A1/A2,2)*A2)/0.01
D2D2=A2-C2
C3C3=ROUNDUP(A1/A2,2)
D3D3=ROUNDDOWN(A1/A2,2)
C5:D5C5=C2*C3
E5E5=SUM(C5:D5)
 
Upvote 0
Solution
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,673
Members
452,937
Latest member
Bhg1984

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