Live-Forum - Die aktuellen Beiträge
Datum
Titel
18.04.2024 18:04:29
18.04.2024 16:33:24
Anzeige
Archiv - Navigation
1624to1628
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

ListBox Probleme

ListBox Probleme
06.06.2018 09:34:15
Antonio
Hallo Gemeinde,
mit diesem Code lade ich item in der ListBox:
Private Sub ListBox5_Click()
Dim rngFind As Range
Dim sSearch As String
Dim i As Integer
ListBox1.Clear
TextBox2.Value = ListBox5.Value
'sSearch = TextBox2.Value
Set rngFind = Columns("B:B").Find(TextBox2.Value, lookat:=xlWhole)
For i = 13 To 96 Step 6
With Worksheets("Chord1")

ListBox1.AddItem .Cells(ListBox5.ListIndex + 2, i)
ListBox1.List(ListBox1.ListCount - 1, 1) = .Cells(ListBox5.ListIndex + 2, i + 1)
ListBox1.List(ListBox1.ListCount - 1, 2) = .Cells(ListBox5.ListIndex + 2, i + 2)
ListBox1.List(ListBox1.ListCount - 1, 3) = .Cells(ListBox5.ListIndex + 2, i + 3)
ListBox1.List(ListBox1.ListCount - 1, 4) = .Cells(ListBox5.ListIndex + 2, i + 4)
ListBox1.List(ListBox1.ListCount - 1, 5) = .Cells(ListBox5.ListIndex + 2, i + 5)
End With
Next i
Mein Problem, egal was ich in der TextBox2 schreibe wird mir immer nur die erste
Zeile dargestellt, (hier untereinander im ListBox).
Ich Weiß das der Fehler hier sein muss:
ListBox1.AddItem .Cells(ListBox5.ListIndex + 2, i)
ListBox1.List(ListBox1.ListCount - 1, 1) = .Cells(ListBox5.ListIndex + 2, i + 1)
ListBox1.List(ListBox1.ListCount - 1, 2) = .Cells(ListBox5.ListIndex + 2, i + 2)
ListBox1.List(ListBox1.ListCount - 1, 3) = .Cells(ListBox5.ListIndex + 2, i + 3)
ListBox1.List(ListBox1.ListCount - 1, 4) = .Cells(ListBox5.ListIndex + 2, i + 4)
ListBox1.List(ListBox1.ListCount - 1, 5) = .Cells(ListBox5.ListIndex + 2, i + 5)
nach viele Versuche (gescheitert) frage ich nun euch, ich komme leider nicht dahinter.
Vielen Dank in Voraus
Antonio

6
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: ListBox Probleme
06.06.2018 10:35:32
Matthias
Moin!
Also dein Suchergebnis (die Range) wird im Codebeispiel auch nicht weiter genutzt. Deshalb ist es egal, was da steht oder auch gefunden wird. Und dein hinzugefügter Eintag ist immer die selbe Zeile nur andere Spalten!? Oder ändert sich in lIstbox5 noch der listindex? Ansonstenändert sich ListBox5.ListIndex + 2 in der ganzen Prozedur niemals. SChreibe mal bitte noch, was der Code eigentlich machen soll. Wozu ist zB die Suche da und was soll mit dem Ergebnis geschehen.
VG
AW: ListBox Probleme
06.06.2018 10:52:42
Antonio
Hi Matthias,
In Tabelle1(Chord1)
habe ich z.Bsp. folgenden stehen:
C.................................
C#...............................
D..................................
usw.
wenn in TextBox2 "C" steht soll mir die entsprechende Zeile auflisten
wenn in TextBox2 "C#" steht soll mir die entsprechende Zeile auflisten
usw.
die Zeilenzelle werden in ListBox1 untereinanander aufgelistet, das klappt auch
mit: .Cells(ListBox5.ListIndex + 2, i + 1)usw.
die Werte die im ListBox1 aufgelistet werden nutze ich als Koordinate, lass dich nicht verwirren.
Antonio
Anzeige
AW: ListBox Probleme
06.06.2018 11:07:49
Antonio
Hallo Matthias,
habe dir eine Beispieldatei vorbereitet:
https://www.herber.de/bbs/user/121990.xlsm
versuch mal in ListBox4 einmal "C" und in ListBox5 "C6" zu wählen.
ListBox1 füllt sich.
versuch mal in ListBox4 einmal "C#" und in ListBox5 "C#6" zu wählen.
ListBox5 füllt sich aber immer noch aus der Zeile "B4" in "Chord1" und nicht aus Zeile "B56"
ich hoffe du weist was ich meine.
Antonio
AW: ListBox Probleme
06.06.2018 11:38:30
Daniel
Hi
ohne dass ich jetzt genau verstehe, was du da machst, aber wenn du bei Auswahl von C# und C#6 die Daten aus Zeile 56 lesen willst, musst du hier:
With Worksheets("Chord1")
ListBox1.AddItem .Cells(ListBox5.ListIndex + 2, i)
ListBox1.List(ListBox1.ListCount - 1, 1) = .Cells(r, i + 1)
ListBox1.List(ListBox1.ListCount - 1, 2) = .Cells(ListBox5.ListIndex + 2, i + 2)
ListBox1.List(ListBox1.ListCount - 1, 3) = .Cells(ListBox5.ListIndex + 2, i + 3)
ListBox1.List(ListBox1.ListCount - 1, 4) = .Cells(ListBox5.ListIndex + 2, i + 4)
ListBox1.List(ListBox1.ListCount - 1, 5) = .Cells(ListBox5.ListIndex + 2, i + 5)
End With
das "ListBox5.ListIndex + 2" durch "rngFind.Row" austauschen.
Gruß Daniel
Anzeige
AW: ListBox Probleme
06.06.2018 11:56:21
Antonio
Hallo Daniel
danke das du dich meldest.
@ das "ListBox5.ListIndex + 2" durch "rngFind.Row" austauschen.
in alle 6 "ListBox5.ListIndex + 2" ?
Antonio
AW: EUREKA!!!
06.06.2018 11:59:24
Antonio
Danke Daniel.
Das wars, alles austauschen.
Vielen Dank
Antonio

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige