let's say here is my sample workbook ("productmovement")
<tbody>
</tbody>
and here is my samlple workbook ("productinventory")
<tbody>
</tbody>
How can I update the remaining stock of fruits on workbook ("productinventory") based on the Total on my workbook ("productmovement")?
sorry im just a newbie in VBA
here is my current code
Private Sub CommandButton1_Click()
Dim lastrow, cell As Long
Dim a, b As Integer
a = 1
lastrow = Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row
Do While Cells(a, 1).Value <> ""
Cells(a, 1).Value
b = Cells(a, 1).Offset(0, 1).Value
Workbooks("productinventory").Sheets("Sheet1").Range("A2:A" & lastrow).Find(What:=Cells(a, 1).Value, LookIn:=xlValues, LookAt:=xlWhole).Activate
' error here "run time error 438"
cell = ActiveCell.Row
Cells(sonsat, 2) = b
a = a + 1
Loop
End Sub
Product | Out | Stock | Total |
apple | 5 | 8 | 3 |
banana | 4 | 9 | 5 |
orange | 3 | 10 | 7 |
<tbody>
</tbody>
and here is my samlple workbook ("productinventory")
Product | Stock | date |
grapes | 10 | |
apple | 8 | |
orange | 10 | |
avocado | 5 | |
orange | 10 | |
banana | 9 |
<tbody>
</tbody>
How can I update the remaining stock of fruits on workbook ("productinventory") based on the Total on my workbook ("productmovement")?
sorry im just a newbie in VBA
here is my current code
Private Sub CommandButton1_Click()
Dim lastrow, cell As Long
Dim a, b As Integer
a = 1
lastrow = Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row
Do While Cells(a, 1).Value <> ""
Cells(a, 1).Value
b = Cells(a, 1).Offset(0, 1).Value
Workbooks("productinventory").Sheets("Sheet1").Range("A2:A" & lastrow).Find(What:=Cells(a, 1).Value, LookIn:=xlValues, LookAt:=xlWhole).Activate
' error here "run time error 438"
cell = ActiveCell.Row
Cells(sonsat, 2) = b
a = a + 1
Loop
End Sub