S
S
Shellr57s2022-02-11 14:56:11
excel
Shellr57s, 2022-02-11 14:56:11

How to generate random numbers under certain conditions?

The task is as follows: in five cells A1-A5, generate random numbers from 0 to 200 (integer) so that the sum of these numbers is not greater than the value in cell B1 (for example, 700).

upd:
=RANDOMBETWEEN(0;B1/5) = doesn't solve the problem because it will generate from 0 to 140, not up to 200. Just as I understand, this function does not allow duplicate random numbers. And for me, this random chance option that I indicated below is quite satisfactory / I need support:
200
0
100
200
200

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander, 2022-02-13
@Shellr57s

The upper bound for numbers 4 and 5 (Sl4, Sl5) should be checked and not just assumed to be 200.
6208dd18e916d416693599.png

=RANDBETWEEN(0;200)
=RANDBETWEEN(0;200)
=RANDBETWEEN(0;200)
=RANDBETWEEN(0;IF(B1-SUM(B3:B5)<200;B1-SUM(B3:B5);200))
=RANDBETWEEN(0;IF(B1-SUM(B3:B6)<200;B1-SUM(B3:B6);200))
=SUM(B3:B7)

G
Grigory Boev, 2022-02-11
@ProgrammerForever

Generate in the range 0..B1/5 , this ensures that the condition is met.
=ЦЕЛОЕ(СЛУЧМЕЖДУ(0;$B$1/5))

M
Mikhail Lyalin, 2022-02-11
@mr_jok

! explicitly only GCX will be
=RANDOMBETWEEN(0;200)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question