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