ich habe ein kleines problem, ausgangsposition ist das Thread https://www.herber.de/forum/cgi-bin/callthread.pl?index=1732266
Wenn ich die Userform Initialize,
Private Sub UserForm_Initialize()
Dim lngAnzahl As Long
With Me.ListBox1
.ColumnCount = 12
'.ColumnWidths = "60;150;60;60;100;100;60;60;"
.ColumnWidths = "1,83cm;6,1cm;3,5cm;1,5cm;3cm;1,8cm;1,8cm;0,7cm;1,8cm;0,7cm;1,8cm;0,7cm;"
End With
ListBox1.Clear
Dim lastrow As Integer
Dim avntValues As Variant
Dim ialngIndex As Long
With Tabelle1
lastrow = .Cells(Rows.Count, 1).End(xlUp).Row
avntValues = .Range("A2:L" & lastrow).Value
End With
ListBox1.List = avntValues
Dim d As Long
With ComboBox1
For d = 2 To 3
.AddItem ThisWorkbook.Worksheets("Drop-Down").Cells(d, 4).Value ' Spalte D
.MatchRequired = True
.ListIndex = 0
Next d
End With
End Sub
löst er sofort das Change Ereignis der Combobox aus und liest somit die Listbox neu ein
Private Sub ComboBox1_Change()
Dim i As Long
Dim lngAnzahl As Long
Dim vArr
Dim lastrow As Integer
With Tabelle1
lastrow = .Cells(Rows.Count, 1).End(xlUp).Row
vArr = .Range("A2:Q" & lastrow)
End With
ListBox1.Clear
For i = 1 To UBound(vArr)
If vArr(i, 16) = ComboBox1.Value Then
ListBox1.AddItem vArr(i, 1)
lngAnzahl = ListBox1.ListCount
ListBox1.List(lngAnzahl - 1, 1) = vArr(i, 2)
ListBox1.List(lngAnzahl - 1, 2) = vArr(i, 3)
ListBox1.List(lngAnzahl - 1, 3) = vArr(i, 4)
ListBox1.List(lngAnzahl - 1, 4) = vArr(i, 5)
ListBox1.List(lngAnzahl - 1, 5) = vArr(i, 6)
ListBox1.List(lngAnzahl - 1, 6) = vArr(i, 7) 'Datum
ListBox1.List(lngAnzahl - 1, 7) = vArr(i, 8)
ListBox1.List(lngAnzahl - 1, 8) = vArr(i, 9) 'Datum
ListBox1.List(lngAnzahl - 1, 9) = vArr(i, 10)
ListBox1.List(lngAnzahl - 1, 10) = vArr(i, 11) 'Datum
ListBox1.List(lngAnzahl - 1, 11) = vArr(i, 12)
If Not IsDate(vArr(i, 7)) Then ListBox1.List(lngAnzahl - 1, 6) = Empty
If Not IsDate(vArr(i, 9)) Then ListBox1.List(lngAnzahl - 1, 8) = Empty
If Not IsDate(vArr(i, 11)) Then ListBox1.List(lngAnzahl - 1, 10) = Empty
End If
Next i
End Sub
wenn ich danach die Sortierfunktion aufrufe , läuft er gegen einen Fehler.
Wenn ich mir dann im Lokalfenster das Array anschaue, sind alle Felder vom Typ Variant/String,
wenn ich das Change Ereignis ausklammere sind die Werte richtig definiert mit z.b. Variant/Date und die Sortierfunktion läuft.
Vielen Dank
Curly