# Thread: 6 Unique Random Numbers (XP; SP3)

1. ## 6 Unique Random Numbers (XP; SP3)

How would one control the random number to only return six unique values?

The code I have been toying with generates duplicate values:

Sub RandomNumbers_6_Unique()
oNo1 = Int((6 * Rnd) +1)
oNo2 = Int((6 * Rnd) +1)
oNo3 = Int((6 * Rnd) +1)
oNo4 = Int((6 * Rnd) +1)
oNo5 = Int((6 * Rnd) +1)
oNo6 = Int((6 * Rnd) +1)

MsgBox oNo1 & "-" & oNo2 & "-" & oNo3 & "-" & oNo4 & "-" & oNo5 & "-" & oNo6

End Sub

This is a test to return only numbers between 1 and 6. Eventually I will expand it and only want 6 unique random numbers returned.

Thanks,
John

2. ## Re: 6 Unique Random Numbers (XP; SP3)

Get yourself the freeware morefunc(tions) addin from

http://longre.free.fr

Regards,
Teunis

3. ## Re: 6 Unique Random Numbers (XP; SP3)

I think you will have to use VBA to do this. Does this <post#=222,852>post 222,852</post: > give you enough to do what you want?

4. ## Re: 6 Unique Random Numbers (XP; SP3)

Sorry,

The morefunc site was updated to

http://xcell05.free.fr/

Regards,
Teunis

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•