ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Random Range with no duplicates (https://www.excelbanter.com/excel-programming/415486-random-range-no-duplicates.html)

Darmahart

Random Range with no duplicates
 
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!

Skinman

Random Range with no duplicates
 
This may be the formula you are seeking
=RANDBETWEEN(9001,9099)
Skinman


"Darmahart" wrote in message
...
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!



Darmahart

Random Range with no duplicates
 
I tried that function, but it does produce duplicates. I can't have duplicate
numbers, but thanks!

"Skinman" wrote:

This may be the formula you are seeking
=RANDBETWEEN(9001,9099)
Skinman


"Darmahart" wrote in message
...
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!




Gary''s Student

Random Range with no duplicates
 
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
--
Gary''s Student - gsnu200799

Ak Man

Random Range with no duplicates
 
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
--
Ak


"Darmahart" wrote:

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

"Skinman" wrote:

This may be the formula you are seeking
=RANDBETWEEN(9001,9099)
Skinman


"Darmahart" wrote in message
...
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!




Darmahart

Random Range with no duplicates
 
Very simple yet effective. Thanks!

"Gary''s Student" wrote:

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
--
Gary''s Student - gsnu200799



All times are GMT +1. The time now is 05:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com