Calculating Random Numbers into a single Number

Cherish1980

New Member
Joined
Aug 23, 2007
Messages
7
Hello,
I know how to calculate random numbers on excel, but I was wondering if there was a formula to calculate random numbers into a single number. For example, If I needed 4 random numbers to equal 652, how would I write that formula? Is it even possible? Please let me know. Thanks!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Here's a way that works if you need exactly four random numbers to add up to a pre-determined sum:
Book1
ABCDEF
1TargetNum 1Num 2Num 3Num 4sum
26504001764727650
Sheet1
 
Upvote 0
...and here's a version that allows you to change how many random numbers are generated:
Book1
ABCDEFGHIJKLMNOPQ
1TargetNum 1Num 2Num 3Num 4Num 5Num 6Num 7Num 8Num 9Num 10Num 11Num 12Num 13Num 14Num 15Num 16
2650325851186172912426199000000
3
4How many numbers:
510
6
7Checksum:
8650
Sheet1


This one is not EXACTLY random. Each "random" number except the n'th one (n=how many numbers do you want) is in the range of 0 - target/n. I did this to prevent it from randomly filling up and generating zeros after that.
 
Upvote 0
Thank you so much!
Now, one more question, can I make it so that the numbers are within a range, like from 100 - 200?
 
Upvote 0
That wasn't as easy as I had thought it would be, but YES it can be done:
Mrexcel random.xls
ABCDEF
1TargetNum 1Num 2Num 3Num 4Num 5
26501931211641720
3
4How many numbers:Possible?Checksum:lower rangeupper range
541650100200
6
7Absolute Max200200200200200
8Max for sum3472562361720
9chosen max2002002001720
10span100100640-100
11chosen min100100136172100
12min for sum47561361720
13absolute min100100100100100
14
15numbers left32100
16lowest sum to come30320110000
17highest sum to come60340120000
Sheet1


You'll get a message of "undefined" if the combination of conditions you impose cannot be met. For example, you can't get add up to 300 using four values each between 100 and 200, nor can you add up to 1200 with those conditions.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

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