Forum Discussion
SD40T-2
Jul 22, 2022Copper Contributor
Dividing a number over a given number of cells with one or no remainder
I work as a professional pyrotechnician. For each display event I have a given number of cues, and a time period in minutes. In the past, I've usually divided the number of cues, but the number...
HansVogelaar
Jul 22, 2022MVP
Let's say the number of cues is in B1 and the number of minutes in B2.
In a cell in row 1, for example D1, enter the formula
=IF(ROW()>$B$2,"",QUOTIENT($B$1,$B$2)+(ROW()<=MOD($B$1,$B$2)))
And fill down to the row whose number is the largest number of minutes you expect, for example to D60.
This version will place the shorter events at the end.
To place them at the beginning:
=IF(ROW()>$B$2,"",QUOTIENT($B$1,$B$2)+($B$2-ROW()<MOD($B$1,$B$2)))
mtarler
Jul 22, 2022Silver Contributor
I believe this will give you that even distribution you want. Again assume cues in B1 and minutes in B2:
=SCAN(0,SEQUENCE(B2),LAMBDA(carry,p,ROUND(B1/B2*p,0)-ROUND(B1/B2*(p-1),0)))
=SCAN(0,SEQUENCE(B2),LAMBDA(carry,p,ROUND(B1/B2*p,0)-ROUND(B1/B2*(p-1),0)))