problem on transferring data to another workbook

astral007

New Member
Joined
Oct 12, 2017
Messages
4
let's say here is my sample workbook ("productmovement")
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
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,213,536
Messages
6,114,211
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top