When using vba, you don't need to do Vlookup. Th macro I will write checks the net stock table for each item in the inward table. If exists, it will add to the line, if it is a new item it will be added to the bottom of the net table.
userform 1
code:
Private Sub cmdadd_Click()
Dim RowCount As Long
Dim f As Integer
For f = 1 To 8
RowCount = Worksheets("Inwards").Range("A1").CurrentRegion.Rows.Count
With Worksheets("Inwards").Range("A1")
.Offset(RowCount, 0) = Controls("txt" & f).Value
.Offset(RowCount, 1) = Controls("txtt" & f).Value
.Offset(RowCount, 2) = Controls("txttt" & f).Value
.Offset(RowCount, 3) = Controls("txtttt" & f).Value
.Offset(RowCount, 4) = Controls("txttttt" & f).Value
End With
Controls("txt" & f).Value = ""
Controls("txtt" & f).Value = ""
Controls("txttt" & f).Value = ""
Controls("txtttt" & f).Value = ""
Controls("txttttt" & f).Value = ""
Next f
End Sub
Private Sub cmdclr_Click()
Dim a As Integer
For a = 1 To 8
Controls("txt" & a).Value = ""
Controls("txtt" & a).Value = ""
Controls("txttt" & a).Value = ""
Controls("txtttt" & a).Value = ""
Controls("txttttt" & a).Value = ""
txt1.SetFocus
Next a
End Sub
Private Sub cmdcls_Click()
Unload Me
End Sub
Private Sub UserForm_Click()
End Sub
Userform2
code:
Private Sub cmdadd_Click()
Dim RowCount As Long
Dim f As Integer
For f = 1 To 10
RowCount = Worksheets("Outwards").Range("A1").CurrentRegion.Rows.Count
With Worksheets("Outwards").Range("A1")
.Offset(RowCount, 0) = Controls("txt" & f).Value
.Offset(RowCount, 1) = Controls("txtt" & f).Value
.Offset(RowCount, 2) = Controls("txttt" & f).Value
.Offset(RowCount, 3) = Controls("txtttt" & f).Value
.Offset(RowCount, 4) = Controls("txttttt" & f).Value
End With
Controls("txt" & f).Value = ""
Controls("txtt" & f).Value = ""
Controls("txttt" & f).Value = ""
Controls("txtttt" & f).Value = ""
Controls("txttttt" & f).Value = ""
Next f
End Sub
Private Sub cmdclr_Click()
Dim a As Integer
For a = 1 To 10
Controls("txt" & a).Value = ""
Controls("txtt" & a).Value = ""
Controls("txttt" & a).Value = ""
Controls("txtttt" & a).Value = ""
Controls("txttttt" & a).Value = ""
txt1.SetFocus
Next a
End Sub
Private Sub cmdcls_Click()
Unload Me
End Sub
Private Sub UserForm_Click()
End Sub
i want to move data from opening stock sheet & inward sheet into net stock inventory, qty is automatic calculated by function in net stock