I would really appreciate any help.
Here is the issue: I want to input details to stock an item. By textbook the user inputs quantity and date and by combobox selects the item. I want the sub to search for this item in stock. If there is stock then to sum the quantites and update the date. Otherwise to add a new row at the stock sheet.
Any help is desirable! thank you in advance
Private Sub CommandButton1_Click()
Dim x As Integer
Dim nextrow As Range
Dim i As Integer
On Error GoTo cmdStock_Click_Error
Set nextrow = Sheet8.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0)
For x = 1 To 4
If Me.Controls("Stock" & x).Value = "" Then
MsgBox "Missing data"
Exit Sub
End If
Next
For i = 1 To 10
If WorksheetFunction.CountIf(Sheet8.Range("D:D"), Me.Stock2.Value) > 0 Then
Cells("E,i").Value = Cells("E,i") + Me.Stock3.Value
Cells("F,i").Value = Me.Stock3.Value
MsgBox "Stock is now updated"
Exit Sub
End If
Next i
For x = 1 To 4
nextrow = Me.Controls("Stock" & x).Value
Set nextrow = nextrow.Offset(0, 1)
Next
'clear
For x = 1 To 4
Me.Controls("Stock" & x).Value = ""
Next
On Error GoTo 0
Exit Sub
cmdStock_Click_Error:
MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure cmdStock_Click of Form frmStock"
End Sub
Aucun commentaire:
Enregistrer un commentaire