Ich habe eine Excel Datenbank die ich mittels VBA Form fülle und pflege.
Nun habe ich ein Textfeld (suchenTextFeld) und Commandbutton (suchenButton)
um die Listbox mit vorhandenen Einträge zu durchsuchen.
Ich möchte im Textfeld ein Wort oder Buchstaben eingeben
und durch klick auf den Commandbutton soll dann die ganze Datenbank Liste
durchsucht und alle Treffer in der Listbox anzeigt werden.
Die suche Funktioniert bereits, jedoch wird mir immer nur ein Treffer
in der Liste angezeigt. Zudem wird nur die erste Spalte durchsucht (Spalte A).
Es sollte jedoch die ganze Liste durchsucht werden.
Das ist mein Code soweit:
Private Sub suchenButton_Click()
Dim LoI As Long
Dim LoZeile As Long
Dim RaFound As Range
Application.ScreenUpdating = False
If suchenTextBox = "" Then
ListBox1.RowSource = "A2:I" & LoLetzte
Else
ListBox1.RowSource = ""
With Worksheets("Datenbank")
Set RaFound = .Columns(1).Find(suchenTextBox & "*", .Range("A1"), , xlWhole, , xlNext)
If Not RaFound Is Nothing Then
For LoI = RaFound.Row To .Columns(1).Find(suchenTextBox & "*", .Range("A65536")
, , xlWhole, , _
_
_
xlprevioius).Row
If UCase(Left(.Cells(LoI, 1), Len(suchenTextBox))) = UCase(suchenTextBox) Then
ListBox1.AddItem .Cells(LoI, 1).Text
ListBox1.List(LoZeile, 1) = .Cells(LoI, 2).Text
ListBox1.List(LoZeile, 2) = .Cells(LoI, 3).Text
ListBox1.List(LoZeile, 3) = .Cells(LoI, 4).Text
ListBox1.List(LoZeile, 4) = .Cells(LoI, 5).Text
ListBox1.List(LoZeile, 5) = .Cells(LoI, 6).Text
ListBox1.List(LoZeile, 6) = .Cells(LoI, 7).Text
ListBox1.List(LoZeile, 7) = .Cells(LoI, 8).Text
ListBox1.List(LoZeile, 8) = .Cells(LoI, 9).Text
ListBox1.List(LoZeile, 9) = .Cells(LoI, 10).Text
LoZeile = LoZeile + 1
End If
Next
End If
End With
End If
Set RaFound = Nothing
Application.ScreenUpdating = True
End Sub
Ich danke bereits jetzt für eure Hilfe!!!Liebe Grüsse
Marina