The BubbleSort() procedure sorts a column of integer values from lowest to highest value : Column « Excel « VBA / Excel / Access / Word






The BubbleSort() procedure sorts a column of integer values from lowest to highest value

 
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

 








Related examples in the same category

1.Select active column
2.Select entire column
3.Select first column to last column
4.converts the Integer to a String representation of the same column.
5.Array to Columns
6.Assign the value to the ColumnWidth property of the ActiveCell using:
7.Assign the column width of one cell to another cell on the active sheet, using:
8.Adjusting Column Widths
9.The Clear method
10.ClearContents method deletes the contents of the range but leaves the formatting intact.
11.ClearFormats method deletes the formatting in the range but not the cell contents.
12.The NumberFormat property represents the number format (expressed as a text string) of the Range object: statement changes the number format of column A to percent with two decimal places
13.Is in last column
14.Change column width
15.Make a range autofit
16.Returning the Last Used Cell in a Column or Row with Worksheet