我需要自定义此气泡排序代码的帮助,以便它将跳过列表框中的第一项,而仅对列表框中其余项进行a-z排序。我迷路了,需要一些指导。谢谢
Dim j As Long
Dim sTemp As String
Dim sTemp2 As String
Dim LbList As Variant
'Store the list in an array for sorting
LbList = Me.WorksheetListBox.List
'Bubble sort the array on the first value
For i = LBound(LbList, 1) To UBound(LbList, 1) - 1
For j = i + 1 To UBound(LbList, 1)
If LbList(i, 0) > LbList(j, 0) Then
'Swap the first value
sTemp = LbList(i, 0)
LbList(i, 0) = LbList(j, 0)
LbList(j, 0) = sTemp
'Swap the second value
sTemp2 = LbList(i, 1)
LbList(i, 1) = LbList(j, 1)
LbList(j, 1) = sTemp2
End If
Next j
Next i
'Remove the contents of the listbox
Me.WorksheetListBox.Clear
'Repopulate with the sorted list
Me.WorksheetListBox.List = LbList