VBA Bubble Sort : Array Sort « Data Type « VBA / Excel / Access / Word

Home
VBA / Excel / Access / Word
1.Access
2.Application
3.Data Type
4.Data Type Functions
5.Date Functions
6.Excel
7.File Path
8.Forms
9.Language Basics
10.Math Functions
11.Outlook
12.PowerPoint
13.String Functions
14.Windows API
15.Word
16.XML
VBA / Excel / Access / Word » Data Type » Array Sort 
VBA Bubble Sort
 
Public Sub BubbleSort()
    Dim tempVar As Integer
    Dim anotherIteration As Boolean
    Dim As Integer
    Dim iterationNum As Integer
    Dim sortArray(10As Integer

    For I = To 11
        sortArray(I - 2= Cells(I, "A").Value
    Next I
    Do
        anotherIteration = False
        For I = To 8
            If sortArray(I> sortArray(I + 1Then
                tempVar = sortArray(I)
                sortArray(I= sortArray(I + 1)
                sortArray(I + 1= tempVar
                anotherIteration = True
            End If
        Next I
        iterationNum = iterationNum + 1
        Cells(1, iterationNum + 2).Value = iterationNum
        For I = To 9
            Cells(I + 2, iterationNum + 2).Value = sortArray(I)
        Next I
    Loop While anotherIteration = True
End Sub

 
Related examples in the same category
1.using dynamic arrays in bubble sort
2.Performing a Binary Search through an Array
3.Quick sort
4.Quick Sort 2
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.