ich habe mal wieder ein Problem das ich selber nicht gelöst bekomme.In meiner Useform befindet sich eine ListBox mit einer ComboBox und einer textBox.In der Combobox gebe ich das Suchkriterium vor und in der TextBox den Suchbegriff.Durch die Auswahl in der ComboBox wollte ich den entsprechenden Code vorgeben damit an der richtigen Stelle in der Tabelle gesucht wird.Habe ich nur ein Suchkriterium funktioniert alles Super.Ab zweien (und die ComboBox hat 7) Suchkriterien bekomme ich nur noch Fehlermeldungen wie z.B "Mehrfachdeklaration im aktuellen Gültigkeitsbereich"..usw! Ich bin nun wirklich kein VBA Experte und war schon froh das ich den Suchcode hin bekommen habe.Aber hier weiss ich nicht weiter.
Kann mir jemand helfen?
Vorab vielen Dank für jeden Lösungsvorschlag
Hier mein verwendeter Code bei 2-Suchkriterien:
Private Sub CommandButton1_Click()
If ComboBox7.Text = "Stellplatz" Then
Dim LoI As Long
Dim LoZeile As Long
Dim RaFound As Range
Application.ScreenUpdating = False
If TextBox11 = "" Then
ListBox1.RowSource = "A2:J" & LoLetzte
Else
ListBox1.RowSource = ""
With Worksheets("Tabelle1")
Set RaFound = .Columns(1).Find(TextBox11 & "*", .Range("A1"), , xlWhole, , xlNext)
If Not RaFound Is Nothing Then
For LoI = RaFound.Row To LoLetzte
If UCase(Left(.Cells(LoI, 1), Len(TextBox11))) = UCase(TextBox11) 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
Else
Exit For
End If
Next
End If
End With
End If
End If
Set RaFound = Nothing
Application.ScreenUpdating = True
If ComboBox7.Text = "Kennzeichen" Then
Dim LoI As Long
Dim LoZeile As Long
Dim RaFound As Range
Application.ScreenUpdating = False
If TextBox11 = "" Then
ListBox1.RowSource = "A2:J" & LoLetzte
Else
ListBox1.RowSource = ""
With Worksheets("Tabelle1")
Set RaFound = .Columns(2).Find(TextBox11 & "*", .Range("B1"), , xlWhole, , xlNext)
If Not RaFound Is Nothing Then
For LoI = RaFound.Row To LoLetzte
If UCase(Left(.Cells(LoI, 2), Len(TextBox11))) = UCase(TextBox11) 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
Else
Exit For
End If
Next
End If
End With
End If
End If
Set RaFound = Nothing
Application.ScreenUpdating = True
End Sub
Gruß Andre