Private
Sub
UserForm_Activate()
Dim
a
As
Range, i
As
Integer
For
Each
a
In
Range(
"A1:A40"
)
If
Trim(a) <>
""
Then
For
i = 0
To
Me
.ComboBox1.LineCount - 1
If
Me
.ComboBox1.List(i) = Trim(a)
Then
GoTo
Weiter
Next
i
Me
.ComboBox1.AddItem Trim(a)
Weiter:
End
If
Next
a
Call
SortComboBox(
Me
.ComboBox1)
End
Sub
Sub
SortComboBox(CB
As
Object
)
Dim
iLast
As
Integer
, iNext
As
Integer
, iTmp
With
CB
For
iLast = 0
To
.ListCount - 1
For
iNext = iLast + 1
To
.ListCount - 1
If
.List(iLast) > .List(iNext)
Then
iTmp = .List(iLast)
.List(iLast) = .List(iNext)
.List(iNext) = iTmp
End
If
Next
iNext
Next
iLast
End
With
End
Sub