ich habe eine Combobox, die unsortiert gefüllt wird. Sie soll nun sortiert werden.
Ich habe hierzu im Archiv einen passenden VBA gefunden und habe in zu meinem VBA ergänzt, aber jetzt werden viele Listeinträge nur noch als 0 angezeigt. Was stimmt an dem VBA nicht?
Vielen Dank und Gruß
Edwin
Private Sub UserForm_Initialize()
'Combo füllen
Dim ws As Worksheet, iRow As Long, col As New Collection
Set ws = Sheets("Produktion")
iRow = 2
On Error Resume Next
Do Until IsEmpty(ws.Cells(iRow, 6))
col.Add ws.Cells(iRow, 6), ws.Cells(iRow, 6)
If Err = 0 Then
cmbSparte.AddItem ws.Cells(iRow, 6)
Else
Err.Clear
End If
iRow = iRow + 1
Loop
'Combo sortieren
Dim iLast As Integer, iNext As Integer, iTmp As Integer
With cmbSparte
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