I need a formula to automatically distribute an amount across multiple cells where the max value of each cell and the order of distribution can be de

Islam Gaber

New Member
Joined
Jan 11, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Im trying to upload a container with boxes , so I need to tell the sheet how many boxes do I have and all the rows will be like (the first row 6,6,6,6,6,3) and I need to know in which row the product will end. Thank you.
 

Attachments

  • Screenshot 2023-01-11 165214.png
    Screenshot 2023-01-11 165214.png
    4.4 KB · Views: 21

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Is this what you're looking for?

In the bottom section I turned the formula into a named range lambda.

DISTRIBUTION
ABCDEFGHIJKL
1
212345678910Total
3166666333
4266416
536666125
646666666244
756666327
8
9
10
1112345678910Total
12166666333
13266416
1436666125
1546666666244
1656666327
Data
Cell Formulas
RangeFormula
B3:B7B3=LET(val,L3,div,6,s,SEQUENCE(,IF(MOD(val,div)=0,val/div,INT(val/div)+1)),MAP(s,LAMBDA(x,IF(x*div<val,div,val-((x-1)*div)))))
B12:B16B12=DISTRIBUTE(L12,6)
Dynamic array formulas.
 
Upvote 0
N.B. When I put the information into a sheet, the data L12:L16 was Text.

I had trouble getting the Lambda suggestion to work and I tried a variety of naming alternatives.
I prepared a simple solution and checked the totals. The numbers did not compute; consequently, I made the text numbers real numbers
and I was Ok. The Lambda also worked correctly.


lrobbo314 please advise what value (named formula) you used for the function Distribute.

The simple solution follows

LAMBDA.xlsm
ABCDEFGHIJKLM
1812345678910TotalNum
1916666630000336
2026640000000163
2136666100000255
2246666666200448
2356666300000275
3a
Cell Formulas
RangeFormula
B19:B23B19=MIN(6,L19)
C19:K23C19=MIN(6,$L19-SUM($B19:B19))
M19:M23M19=COUNTIF(B19:K19,">0")
 
Upvote 0
This is how I wrote the formula for the 'DISTRIBUTE' function.

Excel Formula:
=LAMBDA(
    total,divisor,
    LET(
        val,total,
        div,divisor,
        s,SEQUENCE(,IF(MOD(val,div)=0,val/div,INT(val/div)+1)),
        MAP(
            s,
                LAMBDA(x,
                    IF(x*div<val,
                        div,
                        val-((x-1)*div)
                    )
                )
        )
    )
)
 
Upvote 0
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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