Hi all, this problem has been giving me headaches all day. I have a string array called a(12) and one single with values called b(12). I want to sort the b(12) from low to high but at the same time sort the a(12) when needed to keep the matches (ex a(4) with b(4). I want to use the bubble sort routine as module.
This is what I have in mind which doesn't work
Instead if I use this one in command button of a user form it worksCode:Sub bsort(a() As String, b() As Single) Dim n As Integer Dim i As Integer, j As Integer For j = n To 1 Step -1 For i = 1 To j - 1 If b(i) > b(i + 1) Then Call swap(b(i), b(i + 1)) Call swap(a(i), a(i + 1)) End If Next Next End Sub
VB Code:
Private Sub CommandButton3_Click() dim a(12) as string, b(12) as single Dim n As Integer, i As Integer n = UBound(a) For j = n To 1 Step -1 For i = 1 To j - 1 If b(i) > b(i + 1) Then Call swap(b(i), b(i + 1)) Call swap(a(i), a(i + 1)) End If Next Next For i = 1 To n Cells(i, 8) = a(i) Cells(i, 9) = b(i) Next i End Sub
I don't see any differences, why is that happening? Thanks in advance![]()




Reply With Quote