On 2002-05-04 09:26, Jay Petrulis wrote:
Hi,
It would probably help if I read the question thoroughly.
You want an exhaustive list with the changes bounded? That means hypergeometric sampling (sampling without replacement).
The following routine might get closer to your goal.
Code:
Sub bounded_random()
Dim x As Long, samplesize As Long
Randomize
samplesize = 25
Cells(1, 1) = Int(Rnd * samplesize) + 1
If samplesize< 2 Then Exit Sub
For x = 2 To samplesize
Cells(x, 1) = Int(Rnd * samplesize) + 1
Do Until Abs(Cells(x, 1) - Cells(x - 1, 1))<= 15 And _
WorksheetFunction.CountIf(Range(Cells(1, 1), Cells(x, 1)), Cells(x, 1)) = 1
Cells(x, 1) = Int(Rnd * samplesize) + 1
Loop
Next x
End Sub
Note that this is *not* foolproof. Imagine your sample is of 100 numbers and the first element is 50 and then it works up to 75. There is a chance that the numbers will never come back down to 1-10 for instance.
It should work well for your sample size, but give it a try and report back.
Bye,
Jay
Sorry,but that's not what I mean.
I need 3 different numbers on a row
They may not have a difference of more then 15 between each number.
Ex: 1 7 12
18 20 25
1 17 22 = not correct
Thanks for help.
This message was edited by Jay Petrulis on 2002-05-04 09:31