RANDBETWEEN

RANDBETWEEN(bottom, top)

Returns the random integer between two values (>=bottom and <=top).

bottomThe smallest integer that will be returned.
topThe largest integer that will be returned.

REMARKS
* Both the values for "bottom" and "top" are inclusive.
* This is a Volatile function and will change everytime a cell on the worksheet is calculated.
* If "bottom" is not an integer, it is truncated.
* If "top" is not an integer, it is truncated.
* If "bottom" > "top", then #NUM! is returned.
* You can use the RAND function to return a random number between zero and one (>=0 and <1).
* You can use the RANDARRAY function to return the array of random numbers between two values (>=min and <max).
* For the Microsoft documentation refer to support.microsoft.com
* For the Google documentation refer to support.google.com

 A
1=RANDBETWEEN(1, 4) = 4
2=RANDBETWEEN(-10, 10) = 8
3=RANDBETWEEN(2, 2) = 2
4=RANDBETWEEN(1, 1.9) = 1
5=RANDBETWEEN(2.1, 2.1) = 3
6=ROUND(RAND()*(40-1)+1, 0) = 34
7=RANDBETWEEN(2.9, 2) = #NUM!
8=RANDBETWEEN(2, 1) = #NUM!
9=RANDBETWEEN("some text", 40) = #VALUE!
10=RANDBETWEEN(1, "some text") = #VALUE!

1 - This returns a random number between 1 and 4.
2 - This returns a random number between -10 and 10.
3 - This returns a random number between 1 and 40 by using the RAND function.

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top