Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender

Forumthread: ListBox über Auswahl ComboBox

ListBox über Auswahl ComboBox
15.01.2009 15:50:00
A.Franz
Hallo...,
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

Anzeige

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Variablendeklaration!...
15.01.2009 16:12:19
Chris
Servus Andre,
ohne weiter auf deinen Suchcode einzugehen:
Du hast die Variablen mehrfach deklariert:
.
.
.
If ComboBox7.Text = "Stellplatz" Then
Dim LoI As Long
Dim LoZeile As Long
Dim RaFound As Range
.
.
.
If ComboBox7.Text = "Kennzeichen" Then
Dim LoI As Long
Dim LoZeile As Long
Dim RaFound As Range
.
.
.
einmal oben reicht, lösch die unteren Dim-Anweisungen in deinem Code.
Gruß
Chris
Anzeige
AW: Variablendeklaration!...
15.01.2009 16:33:26
A.Franz
Hallo Chris,
Du hast Recht, das war der Fehler - funktioniert jetzt super !!!
Vielen Dank für die schnelle Hilfe..:-)
Gruß Andre
;

Forumthreads zu verwandten Themen

Anzeige
Anzeige
Anzeige
Anzeige
Entdecke relevante Threads

Schau dir verwandte Threads basierend auf dem aktuellen Thema an

Alle relevanten Threads mit Inhaltsvorschau entdecken
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Entdecke mehr
Finde genau, was du suchst

Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden

Suche nach den besten Antworten
Unsere beliebtesten Threads

Entdecke unsere meistgeklickten Beiträge in der Google Suche

Top 100 Threads jetzt ansehen
Anzeige