Generating random numbers from a given range
On Feb 2, 4:11*pm, Darren wrote:
I want to generate 4 random numbers from a range of 1 through to 24. Each
number has to be different from the other 3 though. Is there a way to do
this?
RANDBETWEEN is in the Analysis ToolPak AddIn, install that first.
n1 = RANDBETWEEN(1, 24)
DO
n2 = RANDBETWEEN(1, 24)
WHILE n2 = n1
DO
n3 = RANDBETWEEN(1, 24)
WHILE n3 = n1 OR n3 = n2
DO
n4 = RANDBETWEEN(1, 24)
WHILE n4 = n1 OR n4 = n2 OR n4 = n3
Phil Hibbs.
|