habe eine Userform mit einer Textbox, in der ein Barcode gescannt wird.
Die zu dieser Barcodenummer gehörenden Daten werden in einer Listbox angezeigt.
Der Cursor soll nun wieder in die Textbox zurück, damit ein weiterer Barcode gescannt werden kann.
Bei mir funktioniert es nicht, auch nicht mit .SetFocus - oder ich habe es an der falschen Stelle platziert.
Wie kann ich das lösen bzw. wer kann mir die Codezeile geben/ergänzen?
Code:
Private Sub TextBox_Scan_AfterUpdate()
Dim c As Range
Dim rngBereich As Range
Dim lngAnzahl As Long
Dim strFirst As String
With Sheets("WE")
Set rngBereich = .Columns("D:D")
Set c = rngBereich.Find(TextBox_Scan, LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
strFirst = c.Address
Do
ListBox1.AddItem .Cells(c.Row, 4)
lngAnzahl = ListBox1.ListCount
ListBox1.List(lngAnzahl - 1, 1) = .Cells(c.Row, 5)
ListBox1.List(lngAnzahl - 1, 2) = .Cells(c.Row, 6)
ListBox1.List(lngAnzahl - 1, 3) = .Cells(c.Row, 7)
ListBox1.List(lngAnzahl - 1, 4) = .Cells(c.Row, 8)
ListBox1.List(lngAnzahl - 1, 5) = .Cells(c.Row, 9)
ListBox1.List(lngAnzahl - 1, 6) = .Cells(c.Row, 10)
ListBox1.List(lngAnzahl - 1, 7) = .Cells(c.Row, 11)
ListBox1.List(lngAnzahl - 1, 8) = .Cells(c.Row, 12)
ListBox1.List(lngAnzahl - 1, 9) = .Cells(c.Row, 13)
Set c = rngBereich.FindNext(c)
Loop While Not c Is Nothing And c.Address strFirst
Else
MsgBox "Palette nicht gefunden", 48
End If
End With
TextBox_Scan.Value = ""
End Sub