Supportnet / Forum / Tabellenkalkulation
ComboBox Datum Sortieren
Frage
Hallo Excelexperten,
brauche mal wieder eure Hilfe zur einer ComboBox (UserForm).
Ich habe einen Code gefunden der Zahlen (Text) in der ComboBox sortiert, gibt es eine Möglichkeit auch Datum zu sortieren?
Ich hoffe ihr habt eine Idee dazu.
Gruß
fedjo
Private Sub UserForm_Initialize()
Dim ixCol As Integer
Dim ixRow As Long
Dim ixRowS As Long
Dim ixRowE As Long
Dim ixList As Integer
ixList = 0
ixCol = 6 ' Column of ListRange (e.g. F = 6)
ixRowS = 9 ' RowStart of ListRange
ixRowE = 514 ' RowEnd of ListRange
ComboBox2.Clear
ComboBox2.AddItem ActiveSheet.Cells(ixRowS, ixCol).Value
For ixRow = ixRowS + 1 To ixRowE
If Not IsEmpty(ActiveSheet.Cells(ixRow, ixCol).Value) Then
For ixList = 0 To ComboBox2.ListCount - 1
If UCase(ComboBox2.List(ixList)) = UCase(ActiveSheet.Cells(ixRow, ixCol).Value) Then Exit For
If UCase(ComboBox2.List(ixList)) > UCase(ActiveSheet.Cells(ixRow, ixCol).Value) Then
ComboBox2.AddItem ActiveSheet.Cells(ixRow, ixCol).Value, ixList
Exit For
End If
Next ixList
If ixList = ComboBox2.ListCount Then
If UCase(ComboBox2.List(ixList - 1)) < UCase(ActiveSheet.Cells(ixRow, ixCol).Value) Then ComboBox2.AddItem ActiveSheet.Cells(ixRow, ixCol).Value
End If
End If
Next ixRow
End Sub