# Determining random numbers that add up to a predetermined sum

Frequent Contributor

# Determining random numbers that add up to a predetermined sum

Hello Everyone,

My goal is to create a random set of numbers that add up to a particular total. In the image below, you'll see a column of 10 numbers and its total in A12. What function would I need to insert in order to randomize the 10 numbers, but still end up with a total of 310?

11 Replies

# Betreff: Determining random numbers that add up to a predetermined sum

How to insert random (integer) numbers between two numbers without repeats in Excel?

This method will apply the RAND function and RANDBETWEEN function to insert random numbers between two numbers into a specified range in Excel. Please view below formulas:

Merci pour votre patience et votre temps.

Nikolino

Je sais que je ne sais rien (Socrate)

# Re: Determining random numbers that add up to a predetermined sum

If duplicate numbers are acceptable then you can use achieve your goal by using below different formuals:
Paste =RANDBETWEEN(1,310) in A1
Paste =IFERROR(RANDBETWEEN(1,(310-SUM(\$C\$1:C1))),0) in A2 & drag till A9
Paste =IF(SUM(C1:C9)=310,0,310-SUM(C1:C9)) in A10

You may also refer the attached file.

Thanks

Tauqeer

# Betreff: Determining random numbers that add up to a predetermined sum

Thank you for the reply sir
But i want take any number with the help of RANDBETWEEN function and end up with a total of 310?

# Re: Determining random numbers that add up to a predetermined sum

Hello Sir,
Thank you for giving the solution

# Betreff: Determining random numbers that add up to a predetermined sum

I only sent you the formulas for the solution.
As far as I can see, you have received a proposal for a solution from Mr tauqeeracma, which I am very pleased for you.

I hope you continue to enjoy Excel

Nikolino
I know I don't know anything (Socrates)

# Re: Determining random numbers that add up to a predetermined sum

It helps! Thank you so much sir

# Betreff: Determining random numbers that add up to a predetermined sum

Thank you so much sir

# Re: Determining random numbers that add up to a predetermined sum

A solution using Excel 365.

``````= LET(
rand,RANDARRAY(N),
upper, 1+INT(target*rand/SUM(rand)),
remainder, MOD(rand,1),
k, SUM(upper) - target,
limit, SMALL(remainder,k),
upper - (remainder<=limit) )``````

where target =310 and N = 10 for the case described.

Even then, I am not absolutely sure that every possibility has an equal probability of being selected.

# Re: Determining random numbers that add up to a predetermined sum

To avoid zero numbers (I guess you mean integers under numbers) and avoid rounding errors we could split the range on 3 parts and calculate as here

# Re: Determining random numbers that add up to a predetermined sum

Hello Sir,
Thank you for giving the solution. Thank you so much sir

# Re: Determining random numbers that add up to a predetermined sum

It worked!!! Thank you so much sir