ich fülle eine 10-spaltige Listbox nach Abfrage einer TextBox mit Daten aus einem Tabellenblatt.
Nun möchte ich noch, dass jede Zeile in der Listbox automatisch von 1 ansteigend nummeriert wird.
Kann mir da jemand mit einer Codezeile weiterhelfen?
Mein Code sieht so aus:
Private Sub TextBox_Scan_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim c As Range
Dim rngBereich As Range
Dim lngAnzahl As Long
Dim strFirst As String
With Sheets("BESTAND")
Set rngBereich = .Columns("A:A")
Set c = rngBereich.Find(TextBox_Scan, LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
If Not c = "" Then
strFirst = c.Address
Do
ListBox1.AddItem .Cells(c.Row, 1)
lngAnzahl = ListBox1.ListCount
ListBox1.List(lngAnzahl - 1, 1) = .Cells(c.Row, 3)
ListBox1.List(lngAnzahl - 1, 2) = .Cells(c.Row, 4)
ListBox1.List(lngAnzahl - 1, 3) = .Cells(c.Row, 5)
ListBox1.List(lngAnzahl - 1, 4) = .Cells(c.Row, 8)
ListBox1.List(lngAnzahl - 1, 5) = .Cells(c.Row, 9)
ListBox1.List(lngAnzahl - 1, 6) = ComboBox_Kunde
ListBox1.List(lngAnzahl - 1, 7) = TextBox_Auftrag
ListBox1.List(lngAnzahl - 1, 8) = .Cells(c.Row, 6)
ListBox1.List(lngAnzahl - 1, 9) = .Cells(c.Row, 7)
Set c = rngBereich.FindNext(c)
Loop While Not c Is Nothing And c.Address strFirst
End If
Else
MsgBox "Palette nicht gefunden!", 48
End If
End With
With TextBox_Scan
.Value = ""
End With
If Raus = 0 Then
Cancel = True
Raus = 1
End If
End Sub