ich habe eine Listbox mit 2Spalten (Stückzahl und Firmenname).
Über ein Textfeld wird bei einer Eingabe die Liste nach möglichen Treffern gefiltert.
Wie muss ich noch eine Schleife einfügen, damit die markierte zeile in das Textfeld eingetragen wird und diese praktisch ausgewählt wird.
Bisher kann nur die eine ausgewählt werden, danach ändert sich nichts mehr.
Vielen Dank
Option Explicit
Dim LoLetzte As Long
Private Sub Lst_Firmenname_Click()
Tx_Stückzahl= Lst_Firmenname
End Sub
Private Sub Tx_Stückzahl_Change()
Dim LoI As Long
Dim LoZeile As Long
Dim RaFound As Range
Application.ScreenUpdating = False
If Tx_Stückzahl= "" Then
Lst_Firmenname.RowSource = "B6:C" & LoLetzte
Else
Lst_Firmenname.RowSource = ""
With Worksheets("Tabelle1")
LoLetzte = IIf(IsEmpty(Cells(Rows.Count, 1)), _
Cells(Rows.Count, 1).End(xlUp).Row, Rows.Count)
Set RaFound = .Range("B6:B" & LoLetzte).Find(Tx_Stückzahl_
& "*", .Cells(LoLetzte, 2), , xlWhole, , xlNext)
If Not RaFound Is Nothing Then
For LoI = RaFound.Row To LoLetzte
If UCase(Left(.Cells(LoI, 2), Len(Tx_Stückzahl))) _
= UCase(Tx_Stückzahl) Then
Lst_Firmenname.AddItem .Cells(LoI, 2)
Lst_Firmenname.List(LoZeile, 1) = .Cells(LoI, 4)
LoZeile = LoZeile + 1
End If
Next
End If
End With
End If
Set RaFound = Nothing
Application.ScreenUpdating = True
End Sub
Private Sub UserForm_Initialize()
With Worksheets("Tabelle1")
LoLetzte = IIf(IsEmpty(Cells(Rows.Count, 1)), _
Cells(Rows.Count, 1).End(xlUp).Row, Rows.Count)
Lst_Firmenname.RowSource = "B6:c" & LoLetzte
Lst_Firmenname.ColumnCount = 2
End With
End Sub