Unique Random Number Generator

T

Tom Barnes

I'm looking for a macro that will generate a unique Random number between
1-2000. The random aspect is obviously not the problem, the unique
requirement is whats got me stumped. Thanks Tom.
 
0

0-0 Wai Wai ^-^

What about using RANDBETWEEN function?
It is not a macro but it appears to suit your need.

RANDBETWEEN(bottom,top)

Bottom is the smallest integer RANDBETWEEN will return.

Top is the largest integer RANDBETWEEN will return.

Example


1
2
3
A B
Formula Description (Result)
=RANDBETWEEN(1,100) Random
number between 1 and 100 (varies)
=RANDBETWEEN(-1,1) Random
number between -1 and 1 (varies)



So in your situation, you can use =RANDBETWEEN(1,2000).
Press "F9" to generate a random number again.

PS: You need to install "Analysis ToolPak add-in" to have this function enabled.
 
J

Jerry W. Lewis

If you want a random sampling without replacement of n<=2000 integers
between 1 and 2000, then put the numbers 1 to 2000 in A1:A2000, put
=RAND() in B1:B2000, then sort A1:B2000 by B1:B2000 and take the first n
numbers from A1:A2000.

Jerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top