In the midst of trying to automate a report and the final step is to take the 2 workbooks and copy all the data (excluding the header) from WB1 to the first empty row of WB2.
The issue I'm having is that it when it copies from WB1 it will paste about 173 rows below the last row of WB2... not sure what I am doing wrong however here is my code.
The issue I'm having is that it when it copies from WB1 it will paste about 173 rows below the last row of WB2... not sure what I am doing wrong however here is my code.
VBA Code:
Sub test()
Dim copywb As Worksheet
Dim pastewb As Worksheet
Dim LastRow As Long
Dim copywblastrow As Long
Dim pastelastrow As Long
Workbooks("WB1").Worksheets("salesorders_1").Activate
Workbooks("WB2.xlsm").Worksheets("sheet1").Activate
Set copywb = Workbooks("WB1.xlsm").Worksheets("salesorders_1")
Set pastewb = Workbooks("WB2.xlsm").Worksheets("sheet1")
copywblastrow = copywb.Cells(copywb.Rows.Count, "C").End(xlUp).Row
pastelastrow = pastewb.Cells(pastewb.Rows.Count, "A").End(xlUp).Offset(1).Row
copywb.range("A2:H" & copywblastrow).copy pastewb.range("A" & pastelastrow)
End Sub