Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1636to1640
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

Zeile von einer Listbox in die andere Listbox

Zeile von einer Listbox in die andere Listbox
15.08.2018 22:14:45
einer
Hallo,
ich habe ein Textfeld, in dem ich eine Artikelnummer eingebe. Danach wird aus einem Tabellenblatt gefiltert und alle zur Artikelnummer gehörenden Palettennummern angezeigt. Die möchte ich jetzt auswählen und die gleiche Zeile aus dem Tabellenblatt in die zweite Listbox kopieren.
Der Code zum Auswählen funktioniert:
Private Sub TextBox1_AfterUpdate()
Dim c As Range
Dim rngBereich As Range
Dim lngAnzahl As Long
Dim strFirst As String
ListBox1.Clear
With Sheets("Bestand")
Set rngBereich = .Columns("B:B")
Set c = rngBereich.Find(TextBox1, LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
strFirst = c.Address
Do
ListBox1.AddItem .Cells(c.Row, 1)
lngAnzahl = ListBox1.ListCount
ListBox1.List(lngAnzahl - 1, 1) = .Cells(c.Row, 2)
ListBox1.List(lngAnzahl - 1, 2) = .Cells(c.Row, 3)
ListBox1.List(lngAnzahl - 1, 3) = .Cells(c.Row, 4)
ListBox1.List(lngAnzahl - 1, 4) = .Cells(c.Row, 5)
ListBox1.List(lngAnzahl - 1, 5) = .Cells(c.Row, 6)
ListBox1.List(lngAnzahl - 1, 6) = .Cells(c.Row, 7)
ListBox1.List(lngAnzahl - 1, 7) = .Cells(c.Row, 8)
Set c = rngBereich.FindNext(c)
Loop While Not c Is Nothing And c.Address  strFirst
End If
End With
End Sub
Der Code zum kopieren gibt mir nur die erste Spalte wieder:
Private Sub CommandButton3_Click()
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then ListBox2.AddItem ListBox1.List(1)
Next i
End Sub
Alle ausgewählten Artikel sollen im Anschluss durch einen weiteren CommandButton in ein anderes Tabellenblatt ("WA") kopiert werden.
Kann mir jemand helfen?
Gruß
Andre

1
Beitrag zum Forumthread
Beitrag zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Zeile von einer Listbox in die andere Listbox
16.08.2018 15:59:24
einer
Hi
Private Sub CommandButton3_Click()
Dim i As Long
With ListBox2
.Clear
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
.AddItem ListBox1.List(i, 0)
.List(.ListCount - 1, 1) = ListBox1.List(i, 1)
.List(.ListCount - 1, 2) = ListBox1.List(i, 2)
'usw.
End If
Next i
End With
End Sub
cu
Chris
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige