You are on page 1of 1

If Me.txtitem.

Value = "" Then


MsgBox "Please enter the Product Name", vbCretical
Exit Sub
End If

If IsNumeric(Me.txtorder.Value) = False Then


MsgBox "Please enter the Order Price", vbCretical
Exit Sub
End If

If IsNumeric(Me.txtsale.Value) = False Then


MsgBox "Please enter the Sale price", vbCretical
Exit Sub
End If

Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("MasterList")
If Application.WorksheetFunction.CountIf(sh.Range("B:B"), Me.txtitem.Value) > 0
Then
MsgBox "This Product is already available in product Master List", vbCritical
Exit Sub
End If

Dim lr As Integer
lr = Application.WorksheetFunction.CountA(sh.Range("A:A"))

sh.Range("A" & lr + 1).Value = lr


sh.Range("B" & lr + 1).Value = Me.txtitem.Value
sh.Range("C" & lr + 1).Value = Me.txtorder.Value
sh.Range("D" & lr + 1).Value = Me.txtsale.Value

Me.txtitem.Value = ""
Me.txtorder.Value = ""
Me.txtsale.Value = ""

MsgBox "Product has been added in Product Master List", vbInformation

You might also like