Public
Sub
sort_allComboboxes()
Dim
box
As
MSForms.Combobox
Dim
idx
As
Integer
For
idx = 1
To
frmFilter.FilterCol.Count
Set
box = frmFilter.FilterCol.Item(idx).Filter
sort_ComboBox box
Set
box = frmFilter.FilterCol.Item(idx).Options
sort_ComboBox box
Next
idx
End
Sub
Public
Sub
QuickSort( _
ByRef
ArrayToSort
As
Variant
, _
ByVal
Low
As
Long
, _
ByVal
High
As
Long
)
Dim
vPartition
As
Variant
, vTemp
As
Variant
Dim
i
As
Long
, j
As
Long
If
Low > High
Then
Exit
Sub
vPartition = ArrayToSort((Low + High) \ 2)
i = Low: j = High
Do
Do
While
ArrayToSort(i) < vPartition
i = i + 1
Loop
Do
While
ArrayToSort(j) > vPartition
j = j - 1
Loop
If
i <= j
Then
austauschen:
vTemp = ArrayToSort(j)
ArrayToSort(j) = ArrayToSort(i)
ArrayToSort(i) = vTemp
i = i + 1
j = j - 1
End
If
Loop
Until
i > j
If
(j - Low) < (High - i)
Then
QuickSort ArrayToSort, Low, j
QuickSort ArrayToSort, i, High
Else
QuickSort ArrayToSort, i, High
QuickSort ArrayToSort, Low, j
End
If
End
Sub
Sub
sort_ComboBox(box
As
MSForms.Combobox)
If
box.ListCount = 0
Then
Else
Dim
l()
As
String
Dim
value
As
String
Dim
idx
As
Integer
Dim
i
As
Integer
ReDim
l(0
To
box.ListCount - 1)
As
String
frmFilter.EnableEvents =
False
value = box.value
box.value = Null
For
i = 0
To
box.ListCount - 1
l(i) = box.List(i)
Next
i
Call
QuickSort(l, 0, box.ListCount - 1)
Do
While
box.ListCount > 0
box.RemoveItem (0)
Loop
For
idx = LBound(l)
To
UBound(l)
box.AddItem (l(idx))
Next
idx
If
IsElement(box, value)
Then
box.value = value
ElseIf
box.Style = 0
Then
box.value = value
Else
box.value = Null
End
If
frmFilter.EnableEvents =
True
End
If
End
Sub