Random Macros.

  • Thread starter Thread starter ken ogden
  • Start date Start date
K

ken ogden

Hi,

Does anybody have, or are smart enough to write, an excel macro that will
produce random numbers WITHOUT duplicates. I can't see to get my head around
this problem
 
Also asked in .newusers. Please don't multipost.

You may provide more details on what you wish the macro to produce and where.

Regards,
Anders Silven
 
Here is one method. It generates 99 numbers without duplicates

Sub alpha
ReDim a(99)
ReDim b(99)
Randomize Timer
For n = 1 To 99
Do
c = Int(99 * Rnd) + 1
Loop While a(c) = 1 Or c = 0 Or c > 99
b(n) = c
a(c) = 1
Next
End Sub
 

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

Back
Top