E
ExcelMonkey
Hi folks. I have been sorting a VBA Array using a bubble sort. I
works fine with when my VBA array is 1-D, but when I change to 2-D it
get a "Subscript out of range" Error.
I have an array called UnitOfferArray
ReDim UnitOfferArray(1 To NumberofRows, 1 To 4)
For X = 1 to 10
Next X
BubbleSort UnitOfferArray
Function BubbleSort(List As Variant)
' Sorts an array using bubble sort algorithm
Dim First As Integer, Last As Integer
Dim i As Integer, j As Integer
Dim Temp As Integer
First = LBound(List)
Last = UBound(List)
For i = 1 To Last - 1
For j = i + 1 To Last
If List(i) > List(j) Then
Temp = List(j)
List(j) = List(i)
List(i) = Temp
End If
Next j
Application.StatusBar = "Sorting " & Round(i / Last * 100, 0)
"%"
Next i
End Functio
works fine with when my VBA array is 1-D, but when I change to 2-D it
get a "Subscript out of range" Error.
I have an array called UnitOfferArray
ReDim UnitOfferArray(1 To NumberofRows, 1 To 4)
For X = 1 to 10
Next X
BubbleSort UnitOfferArray
Function BubbleSort(List As Variant)
' Sorts an array using bubble sort algorithm
Dim First As Integer, Last As Integer
Dim i As Integer, j As Integer
Dim Temp As Integer
First = LBound(List)
Last = UBound(List)
For i = 1 To Last - 1
For j = i + 1 To Last
If List(i) > List(j) Then
Temp = List(j)
List(j) = List(i)
List(i) = Temp
End If
Next j
Application.StatusBar = "Sorting " & Round(i / Last * 100, 0)
"%"
Next i
End Functio