By 'it won't work' I meant that either the first half or second half would not work. Because you were being inconsistent in how you were using the same variable.
Like I said in the last post, I don't know what you were trying to use
row_index as, because you used it in the sort as if it were an array, then you used it as if it was a number. So inevitably there was a type mismatch. (Either one use, or the other was correct, I didn't know which)
Change your code to this
CODE
Dim temp As String
Dim i As Integer
Dim n As Integer
' >> Sort the array
For i = LBound(types, 2) To UBound(types, 2) - 1
For n = i To UBound(types, 2)
If types(1, i) > types(1, n) Then
' Swap the array elements
temp = types(1, i)
types(1, i) = types(1, n)
types(1, n) = temp
End If
Next n
Next i
So had two actual problems (that I know of)
- You tried to use row_index in your sort, as if it were an array. I had no idea whether it was an array or number, so how was I supposed to know which half worked for you?
- You didn't swap the items in the sort after comparing them.
In future, it would help us help you, if you showed the definition for each variable you use. Thanks.
Do you understand how everything works? Or do you want further explanation on something?
This post has been edited by Nayana: 23 Jan, 2008 - 05:15 PM