I'm writing a macro that opens a number of different workbooks, copies data from each, and compiles into a single "master" workbook. In the below code example, wb2 is one of the workbooks and I'm copying from, and wb1 is the master.
lrow3A is the last row of data in the source workbook. Lrow3 is the last row of data in the master workbook.
lrow3A = wb2.Sheets("DCF3").Cells(1048576, 2).End(xlUp).Row
wb2.Sheets("DCF3").Range(Cells(6, 1), Cells(lrow3A, 16)).Copy _
Destination:=wb2.Worksheets("DCF3").Cells(lrow3 + 1, 2)
I'm getting a "Subscript out of range" error on the copy line.
Cells()
too. I think you need:wb2.Sheets("DCF3").Range(wb2.Sheets("DCF3").Cells(6, 1), wb2.Sheets("DCF3").Cells(lrow3A, 16)).Copy
– BruceWayne.Range(Cells(6, 1), Cells(lrow3A, 16))
lacks proper parent worksheet referencing. See this. – user4039065