by Menlaan » Tue Feb 06, 2007 12:28 pm
Give this a shot
Sub MenlaanRules()
Dim Total, i, j As Integer
Dim NumArray() As Double
Dim Num1, Num2, Ran1, Ran2 As Double
Total = InputBox("N00b, enter number here")
ReDim NumArray(Total - 1, 1)
For i = 0 To Total - 1
NumArray(i, 0) = i + 1
NumArray(i, 1) = Rnd()
Next i
For i = 0 To Total - 1
For j = i To Total - 1
If NumArray(j, 1) < NumArray(i, 1) Then
Num1 = NumArray(i, 0)
Num2 = NumArray(j, 0)
NumArray(i, 0) = Num2
NumArray(j, 0) = Num1
Ran1 = NumArray(i, 1)
Ran2 = NumArray(j, 1)
NumArray(i, 1) = Ran2
NumArray(j, 1) = Ran1
End If
Next j
Next i
For i = 0 To Total - 1
Range("A" & i + 1) = NumArray(i, 0)
Next i
End Sub