AW: und hier solltest du noch...
25.01.2021 17:47:17
Werner
Hallo,
sorry, da hab ich nicht aufgepasst.
Die Suche wird jetzt in der Spalte Artikelnummer durchgeführt und nichgt mehr in der Spalte Paletten ID. Dort hattest du doppelte ID drin und mit Find findest du immer nur den ersten Treffer.
Private Sub CommandButton_buchen_Click()
Dim suche As Range, x As Long
With ListBox1
If .ListIndex > -1 Then
x = .List(.ListCount - 1)
Set suche = Sheets("BESTAND").Columns(2).Find(.Column(2, .ListIndex), _
LookIn:=xlValues, lookat:=xlWhole)
End If
End With
With TextBox_MengePAL
If IsNumeric(TextBox_Bedarf) Then
If CLng(TextBox_Bedarf) > CLng(.Value) Then
MsgBox ("Menge nicht ausreichend - Position wird nicht gebucht ! ")
Exit Sub
End If
Else
MsgBox "Fehler: Der eingetragene Wert ist nicht numerisch."
Exit Sub
End If
End With
With Worksheets("BESTAND")
If Not suche Is Nothing Then
If .Cells(suche.Row, 3) - CLng(TextBox_Bedarf) = 0 Then
.Rows(suche.Row).Delete
Else
.Cells(suche.Row, 3) = .Cells(suche.Row, 3) - CLng(TextBox_Bedarf)
End If
End If
End With
With ListBox2
.AddItem TextBox_PALID
.List(.ListCount - 1, 1) = TextBox_Bedarf
.List(.ListCount - 1, 2) = TextBox_ArtNR
.List(.ListCount - 1, 3) = TextBox_Bez
.List(.ListCount - 1, 4) = TextBox_Block
.List(.ListCount - 1, 5) = TextBox_Gang
.List(.ListCount - 1, 6) = TextBox_Platz
End With
ListBox1.Clear
TextBox_Artikel.SetFocus
TextBox_Bedarf.Value = ""
TextBox_Artikel.Value = ""
Set suche = Nothing
End Sub
Den Code zum Kopieren in den Warenkorb hab ich auch etwas angepasst.
Private Sub CommandButton1_Click()
' in BESTAND kopieren
Dim last As Integer
With Worksheets("WA")
last = .Cells(.Rows.Count, 1).End(xlUp).Offset(1).Row
For i = 0 To ListBox2.ListCount - 1
.Cells(last, 1) = TextBox_Auftrag
.Cells(last, 2) = ListBox2.List(i, 2)
.Cells(last, 3) = ListBox2.List(i, 3)
.Cells(last, 4) = ListBox2.List(i, 1)
If IsNumeric(ListBox2.List(i, 4)) Then
.Cells(last, 4) = CDbl(ListBox2.List(i, 4))
End If
.Cells(last, 5) = TextBox_Kunde
.Cells(last, 6) = CDate(TextBox_Datum)
Next
End With
TextBox_Auftrag.Value = ""
TextBox_Kunde.Value = ""
TextBox_Artikel.Value = ""
TextBox_PALID.Value = ""
TextBox_MengePAL.Value = ""
TextBox_ArtNR.Value = ""
TextBox_Bez.Value = ""
TextBox_Block.Value = ""
TextBox_Gang.Value = ""
TextBox_Platz.Value = ""
ListBox2.Clear
End Sub
Gruß Werner