View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bill Kuunders Bill Kuunders is offline
external usenet poster
 
Posts: 303
Default How do I get random numbers from a certain range?

Set up a table in Dand E columns with the D column from 1 to 468
and E column is your list of unique numbers
in B column you enter a vlookup formula and extend it to 64 rows
=VLOOKUP(A1,$D$1:$E$468,2,FALSE)

Assign the following macro to a button

Sub TheBestLuckyLottoPicker()
Dim t As Integer, m As Integer
k = 64: n = 468
Do While m < k
Randomize
If (n - t) * Rnd() < k - m Then
m = m + 1
Cells(m, 1) = t + 1
End If
t = t + 1
Loop
End Sub

This macro will produce 64 random numbers from 1 to 468
they will be sorted in the A column
the lookup formula will give you your unique numbers.

Greetings from New Zealand

"Random numbers" <Random wrote in message
...
I have 468 unique numbers and need to select, at random, 64 numbers that do
not repeat. How do I get Excel to do this?