Public Sub BubbleSort()
Dim tempVar As Integer
Dim anotherIteration As Boolean
Dim I As Integer
Do
anotherIteration = False
For I = 1 To 9
If Cells(I, "A").Value > Cells(I + 1, "A").Value Then
tempVar = Cells(I, "A").Value
Cells(I, "A").Value = Cells(I + 1, "A").Value
Cells(I + 1, "A").Value = tempVar
anotherIteration = True
End If
Next I
Loop While anotherIteration = True
End Sub
|