Roderick_E
Well-known Member
- Joined
- Oct 13, 2007
- Messages
- 2,051
I found this code and it works great to sort by the first column of my 4 column list box but I want the open to sort by the other columns. I will have the user click the label above the column so I only need to know what to change to indicate sorting by column 1 2 3 (default column 0 as listbox columns start with 0)
I thought changing the zero in red would do it, but nope
Code:
Private Sub Label3_Click() ' sort list box by quote number
'Sorts ListBox List
Dim i As Long, j As Long, x As Long, sTemp As String
With mainform.searchbox
For j = LBound(.List) To UBound(.List) - 1 Step 1
For i = LBound(.List) To UBound(.List) - 1 Step 1
If .List(i) > .List(i + 1) Then
[COLOR=#ff0000]For x = 0 To (.ColumnCount - 1) Step 1
[/COLOR] sTemp = .List(i, x)
.List(i, x) = .List(i + 1, x)
.List(i + 1, x) = sTemp
Next x
End If
Next i
Next j
End With
End Sub
I thought changing the zero in red would do it, but nope