Public Sub BubbleSort2()
Dim tempVar As Integer
Dim anotherIteration As Boolean
Dim I As Integer
Dim myArray(10) As Integer
For I = 1 To 10
myArray(I - 1) = Cells(I, "A").Value
Next I
Do
anotherIteration = False
For I = 0 To 8
If myArray(I) > myArray(I + 1) Then
tempVar = myArray(I)
myArray(I) = myArray(I + 1)
myArray(I + 1) = tempVar
anotherIteration = True
End If
Next I
Loop While anotherIteration = True
For I = 1 To 10
Cells(I, "B").Value = myArray(I - 1)
Next I
End Sub
|