AW: Fehler beim Schließen/Druck aus Userform
12.12.2020 19:37:22
Andre
der Fehler ist beim "TextBox-Artikel-AfterUpdate"-Event:
Private Sub TextBox_Artikel_AfterUpdate()
Dim boVorhanden As Boolean, ws As Worksheet
Dim zeile As Long, letzte As Long
Set ws = ThisWorkbook.Sheets("BESTAND")
letzte = ws.Cells(Rows.Count, 6).End(xlUp).Row
With ws
For zeile = 2 To letzte
If CLng(.Cells(zeile, 2)) = CLng(TextBox_Artikel) Then
boVorhanden = True
ListBox1.AddItem
ListBox1.List(ListBox1.ListCount - 1, 0) = .Cells(zeile, 1)
ListBox1.List(ListBox1.ListCount - 1, 1) = .Cells(zeile, 3)
ListBox1.List(ListBox1.ListCount - 1, 2) = .Cells(zeile, 2)
ListBox1.List(ListBox1.ListCount - 1, 3) = .Cells(zeile, 4)
ListBox1.List(ListBox1.ListCount - 1, 4) = .Cells(zeile, 7)
ListBox1.List(ListBox1.ListCount - 1, 5) = .Cells(zeile, 8)
ListBox1.List(ListBox1.ListCount - 1, 6) = .Cells(zeile, 9)
End If
Next
End With
If Not boVorhanden Then
Me.ListBox1.Clear
MsgBox "Die Artikel-Nummer ist nicht vorhanden!"
End If
Set ws = Nothing
End Sub
Die Zeile "If CLng(.Cells(zeile, 2)) = CLng(TextBox_Artikel) Then" wird dabei gelb markiert.