Ich komme leider über die Archiv Suche zu keinem zufriedenstellenden Ergebnis.
Wie kann ich über diesen Code (hier aus diesem Archiv), der übrigens super läuft,
Sub SortListBox()
Dim iLast As Integer, iNext As Integer
Dim iTmp
With ListBox1
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
in einer ListBox die 2. Spalten sortieren. Im Moment sortiert er nur die 1. Spalte.
Eingelesen wird die Listbox wie folgt. ( übrigens auch aus diesem Archiv = ich danke dafür! )
Private Sub UserForm_initialize()
Dim i As Integer
Dim sh As Worksheet
Set sh = Sheets("Übersicht")
For i = 4 To 103
If sh.Cells(i, 5) "" And sh.Cells(i, 4) "" And Month(Cells(i, 5)) = Month(Date) - 1 _
Then
ListBox1.AddItem sh.Cells(i, 5) '5 = Spalte E
ListBox1.List(ListBox1.ListCount - 1, 1) = sh.Cells(i, 4) '4 = Spalte D
End If
If sh.Cells(i, 5) "" And sh.Cells(i, 4) "" And Month(Cells(i, 5)) = Month(Date) Then
ListBox2.AddItem sh.Cells(i, 5) '5 = Spalte E
ListBox2.List(ListBox2.ListCount - 1, 1) = sh.Cells(i, 4) '4 = Spalte D
End If
If sh.Cells(i, 5) "" And sh.Cells(i, 4) "" And Month(Cells(i, 5)) = Month(Date) + 1 _
Then
ListBox3.AddItem sh.Cells(i, 5) '5 = Spalte E
ListBox3.List(ListBox3.ListCount - 1, 1) = sh.Cells(i, 4) '4 = Spalte D
End If
Next i
Call SortListBox
End Sub
Für Eure Hilfe danke ich im Voraus.
Gruß, Mike