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 a decimal, then you could get a value outside the range.
* If "top" is a decimal, then you could get a value outside the range.
* 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).
* You can use the ROUND function to return the number rounded to a specified number of digits.
* For the Microsoft documentation refer to support.microsoft.com
* For the Google documentation refer to support.google.com

 A
1=RANDBETWEEN(1, 4) = {1,2,3,4}
2=RANDBETWEEN(-5, 5) = {-5,-4,-3,-2,-1,0,1,2,3,4,5}
3=RANDBETWEEN(2, 2) = 2
4=RANDBETWEEN(1, 1.9) = 1
5=RANDBETWEEN(1, 2.9) = {1,2}
6=RANDBETWEEN(8.9, 10) = {9,10}
7=RANDBETWEEN(8.1, 10) = {9,10}
8=RANDBETWEEN(1.01, 1.9) = 2
9=RANDBETWEEN(1.5, 1.9) = 2
10=RANDBETWEEN(2.01, 2.1) = 3
11=ROUND(RAND()*(40-1)+1, 0) = 12
12=RANDBETWEEN(3, 2) = #NUM!
13=RANDBETWEEN("some text", 40) = #VALUE!

1 - This returns a random number between 1 and 4.
2 - This returns a random number between -5 and 5.
3 - This will always return the number 2.
4 - This will always return the number 1.
5 - This will return the number 1 or 2.
6 - This will return the number 9 or 10.
7 - This will return the number 9 or 10.
8 - This will always return the number 2. This value is outside the range.
9 - This will always return the number 2. This value is outside the range.
10 - This will always return the number 3.
11 - This returns a random number between 1 and 40 (using the RAND function).
12 - If "top" < "bottom", then #NUM! is returned.
13 - If any of the values are non numerical then #VALUE! is returned.

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