Random Range with no duplicates

D

Darmahart

Here is my situation: I have a list of college classes. With each class -
lets say ENGL-1301 I need to generate a series of random section numbers with
no duplicates between 9001-9099. Then on the next class such as ENGL-1302 I
need to start over with the number system. There are different numbers of
classes in one class name - lets say ENGL-1301 has 20 sections and ENGL-1302
has 9 sections.

Thanks for any help!
 
D

Darmahart

I tried that function, but it does produce duplicates. I can't have duplicate
numbers, but thanks!
 
G

Gary''s Student

In E1 thru E99 enter 9001 thru 9099.
In F1 thru F99 enter =RAND()

Sort columns E & F by F

If you want three random values, pick E1, E2, and E3
If you want four random values, pick E1, E2, E3, and E4

To re-shuffle, just re-sort
 
A

Ak Man

U can use this vba code:

Randomize
Cells(1, 9) = Int(99 * Rnd + 9001)
For i = 2 To 99
Do
Stopind = False
Randomize
x= Int(99 * Rnd + 9001)
Set foundCell = Range("I1", _
Range("I1").End(xlDown).Address).Find(x)
If Not (foundCell Is Nothing) Then
Stopind = True
End If
Loop Until Not Stopind
Cells(i, 9) = x
Next
 

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