Public Sub DynamicBubble()
Dim tempVar As Integer
Dim anotherIteration As Boolean
Dim I As Integer
Dim arraySize As Integer
Dim myArray() As Integer
Do
arraySize = I
I = I + 1
Loop Until Cells(I, "A").Value = ""
ReDim myArray(arraySize - 1)
For I = 1 To arraySize
myArray(I - 1) = Cells(I, "A").Value
Next I
Do
anotherIteration = False
For I = 0 To arraySize - 2
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 arraySize
Cells(I, "B").Value = myArray(I - 1)
Next I
End Sub
|