Randomly fill cells with numbers to sum up to a given total

Lux Aeterna

Board Regular
Joined
Aug 27, 2015
Messages
191
Office Version
  1. 2019
Platform
  1. Windows
Hello again! :)
I've got a total score here that I'd like to split to several smaller random numbers. For example, N3=22. I'd like a formula preferably that would add numbers to cells O3:X3 that sum up to 22. Numbers I can use are only even ones, from 0 to 6 (0, 2, 4, 6).

I'd rather have a formula because sometimes I might need to use odd numbers as well and I'd like to be adjust it myself.

1655830690809.png


PS. If what I am asking for is difficult, we could do it the other way. Meaning, add numbers to O3:X3 that sum up to a given range (range is in cell M3).

Thanks a lot!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I was tinkering with some of the constants to get a more even distribution. I'm not crazy about it.

Book1
NOPQRSTUVWX
2Final Valueq1q2q3q4q5q6q7q8q9q10
3222206084000
4144220002004
5260802464200
6100200080000
744010644810200
Sheet1
Cell Formulas
RangeFormula
O3:O7O3=RANDBETWEEN(0,N3/6)*2
P3:S7P3=IFERROR(INT(RANDBETWEEN(0,($N3-SUM($O3:O3))/3)/2)*2,0)
T3:W7T3=IFERROR(INT(RANDBETWEEN(0,$N3-SUM($O3:S3))/2)*2,0)
X3:X7X3=N3-SUM(O3:W3)
 
Upvote 0
Upvote 0
here is my attempt.
Unfortunately I've got office 2019 and it doesn't support let function.
I was tinkering with some of the constants to get a more even distribution. I'm not crazy about it.
This seemed to work, but the only possible cell values are 0, 2, 4 and 6. Don't worry about how the values get distributed.
 
Last edited:
Upvote 0
Unfortunately I've got office 2019

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
Thanks, just did it!
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,893
Members
449,097
Latest member
dbomb1414

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