ich möchte gern die Anzahl der Einträge in einer Listbox, im Tabellenblatt summieren.
Dazu ist in Spalte 2 der Listbox eine Artikelnummer die sich auch im Tabellenblatt befinden.
Klickt man auf einen Button, soll die Spalte 2 der Listbox auf die Anzahl identischer Artikelnummern geprüft und im Tabellenblatt die Anzahl auf den bestehenden Eintrag erhöht werden.
Folgendes habe ich probiert, jedoch scheitere ich da mit meinen Kenntnissen und hoffe auf eure Unterstützung:
Private Sub CommandButton1_Click()
Dim WbZ As Workbook, WsZ As Worksheet, ImportListe As Long, i As Long
aktWB As Workbook, Result As Long, raFund As Range
Set aktWB = ActiveWorkbook
Set WbZ = Workbooks.Add(template:=xlWBATWorksheet)
Set WsZ = WbZ.Worksheets(1)
ImportListe = WsZ.Cells(WsZ.Rows.Count, 1).End(xlUp).Row
For i = 0 To ListBox1.ListCount - 1
Set raFund = Worksheets("Artikel").Range("C2:C12").Find(.List(i, 1), LookIn:=xlValues, LookAt:= _
xlWhole)
Result = raFund.Value + 1
Application.ScreenUpdating = False
With UserForm1.ListBox1
.Selected(i) = True
WsZ.Cells(ImportListe + 1, 1) = .List(i, 2) 'Artikelnummer
WsZ.Cells(ImportListe + 1, 2).NumberFormat = "@"
WsZ.Cells(ImportListe + 1, 2) = .List(i, 1) 'EAN
WsZ.Cells(ImportListe + 1, 3).NumberFormat = "@"
ImportListe = ImportListe + 1
End With
Next i
Unload UserForm1
UserForm1.Show
End Sub