Unique Random Numbers
I wrote:
"Paul Black" wrote:
Unfortunately the UDF produces replica numbers.
What I would prefer is a Sub that produces 5,6,7
or whatever number combinations without replacement
until ALL the numbers have been used.
It does exactly that if you put =uniqRandBetween(1,34)
into 34 different cells in any arrangement that you wish.
(Previously, you mention 6 rows of 5 and 1 row of 4.)
After populating the 34 cells as your desire, you can generate a new set of
34 unique random values by pressing ctrl+alt+F9.
Alternatively, you could execute the following macro, changing the cell
arrangement as you wish.
Sub genAll()
Dim i as Long, j as Long
Randomize
For i = 1 to 6
For j = 1 to 5
Cells(i,j) = uniqRandBetween(1,34)
Next
Next
For j = 1 to 5
Cells(7,j) = uniqRandBetween(1,34)
Next
End Sub
|