generating a set of random numbers to total a set value

yaldan

New Member
Joined
Jan 15, 2007
Messages
1
Is it possible to generate a set of random numbers between say 50 - 150 whereby the sum of those random numbers totals a value in the spreadsheet which is determined by two other values in the spreadsheet?

Eg: value 1 = 10, value 2 = 300. The difference = 290. Now generate 6 or so random numbers between 50 - 150 that come to a total of 290.

If so could you helpme with formula or script.

Regards

Yaldan
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hello , may be the wording of my question was not vert clear.

i want formula give me random values M (lets say 5 values ) , these values are integers not fractions , sum of them equal X , lets say 100
Example : results can be like : 5,10,14,9,62

Thanks for your support.
 
Upvote 0
if they are random you might get 62,31,9 so target exceeded - a macro would abort and start again at this stage - easy to write

if 4 numbers were 15,20,25, 29, then could I make the last one 11 ?
 
Upvote 0
Dear

this is not correct , this formula for example give the perfect results but unfortunately it allows fractions , but total will be always equal to X (100 here)

=A1*100/SUM(A$1:A$M) where M equal 10 for example (10 random values).

i wish i have modification to this formula that allows only integer values (not fraction) and keep sum up to 100 exact
 
Upvote 0
use a macro to generate 5 random different integers and if they add up to exactly 100 print them out, or restart macro.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,021
Latest member
Mohamed Magdi Tawfiq Emam

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