AW: listbox überwachen
05.05.2019 20:51:03
Sepp
Hallo Thomas,
in das Modul von UserForm1.
Private Sub UserForm_Activate()
Dim lngIndex As Long, lngC As Long
With nicht_Bearbeitet
For lngIndex = 0 To ListBox2.ListCount - 1
If Not ListBox2.List(lngIndex, 2) Like "*möglich*" Then
.ListBox1.AddItem ListBox2.List(lngIndex, 0)
For lngC = 1 To 3
.ListBox1.List(.ListBox1.ListCount - 1, lngC) = _
IIf(lngC = 1, Format(ListBox2.List(lngIndex, lngC), "dd.mm.yyy"), ListBox2.List(lngIndex, lngC))
Next
End If
Next
Call SortListBox(.ListBox1, 0, .ListBox1.ListCount - 1, 1)
.Show
End With
End Sub
Private Sub SortListBox(ByRef TheBox As MSForms.ListBox, LowerBound As Long, UpperBound As Long, SortColumn As Byte)
'original by Nepumuk
Dim lngIndex1 As Long, lngIndex2 As Long
Dim vntTemp As Variant, vntBuffer As Variant
Dim bytIndex As Byte
lngIndex1 = LowerBound
lngIndex2 = UpperBound
vntTemp = TheBox.List((LowerBound + UpperBound) \ 2, SortColumn)
Do
Do While TheBox.List(lngIndex1, SortColumn) < vntTemp
lngIndex1 = lngIndex1 + 1
Loop
Do While vntTemp < TheBox.List(lngIndex2, SortColumn)
lngIndex2 = lngIndex2 - 1
Loop
If lngIndex1 <= lngIndex2 Then
For bytIndex = 0 To TheBox.ColumnCount - 1
vntBuffer = TheBox.List(lngIndex1, bytIndex)
TheBox.List(lngIndex1, bytIndex) = TheBox.List(lngIndex2, bytIndex)
TheBox.List(lngIndex2, bytIndex) = vntBuffer
Next
lngIndex1 = lngIndex1 + 1
lngIndex2 = lngIndex2 - 1
End If
Loop Until lngIndex1 > lngIndex2
If LowerBound < lngIndex2 Then Call SortListBox(TheBox, LowerBound, lngIndex2, SortColumn)
If lngIndex1 < UpperBound Then Call SortListBox(TheBox, lngIndex1, UpperBound, SortColumn)
End Sub
VBA/HTML-CodeConverter, AddIn für Office 2002-2016 - in VBA geschrieben von Lukas Mosimann. Projektbetreuung:RMH Software & Media
Code erstellt und getestet in Office 16 - mit VBAHTML 12.6.0