AW: Probleme mit Listbox
18.12.2020 18:33:51
Siegfried
So sieht der Code aus:
Private Sub fuellen(by value ssucheintrag as string)
Dim Loletzte As Long
Dim Loi As Long
Loletzte = IIf(IsEmpty(Cells(Rows.Count, 2)), Cells(Rows.Count, 2).End(xlUp).Row, Rows.Count)
For Loi = 2 To Loletzte
If InStr(1, Cells(Loi, 1), ssucheintrag, vbTextCompare) > 0 _
Or InStr(1, Cells(Loi, 3), ssucheintrag, vbTextCompare) > 0 Then
UFsuchen.ListBox1.AddItem Cells(Loi, 1)
UFsuchen.ListBox1.List(ListBox1.ListCount - 1, 2) = Cells(Loi, 3)
End If
Next Loi
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim text1, text2, text3 As String
text1 = ListBox1.List(ListBox1.ListIndex, 0)
text2 = ListBox1.List(ListBox1.ListIndex, 1)
text3 = ListBox1.List(ListBox1.ListIndex, 2)
Sucheintrag = ListBox1.List(ListBox1.ListIndex, 0)
End Sub
Funktioniert ja auch, nur das Event ListBox1_DblClick kann ich nicht anwenden, da nach dem Aufruf des Unterprogramms "fuellen()" zwar die Listbox gefüllt wird aber das Programm nach beenden des Unterprogramms weiter läuft und ich in der Listbox nichts auswählen kann.