# Calculating Random Numbers into a single Number

#### Cherish1980

##### New Member
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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

#### gardnertoo

##### Well-known Member
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

#### gardnertoo

##### Well-known Member
...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.

#### Cherish1980

##### New Member
Thank you so much!
Now, one more question, can I make it so that the numbers are within a range, like from 100 - 200?

#### gardnertoo

##### Well-known Member
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.

Replies
10
Views
269
Replies
4
Views
356
Replies
7
Views
185
Replies
2
Views
231
Replies
1
Views
207

1,190,637
Messages
5,982,055
Members
439,752
Latest member
jscratch

### 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.

### Which adblocker are you using?

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

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