Hey Everyone,
I'm new to VBA and have a problem that is driving me up a wall! Any help would be greatly appreciated!
My eventual goal is to loop through all active workbooks and copy each region (minus a few rows at the top) and then paste these rows in succession in another workbook. All 10+ of these sheets should have their data stacked on top of each other in the new worksheet with one blank row in between. Here is the code I have used below...
Public Sub CopoyPastaInvoices()
'Copying the data in each open worksheet and offsetting the top three lines
Dim rng As Range
Dim Lastrow As Long
Set rng = Workbooks("C3002171210_35267058.csv").Worksheets(1).Range("A1:A4").CurrentRegion
Set rng = rng.Offset(3, 0)
Set rng = rng.Resize(rng.Rows.Count - 3)
rng.Copy ThisWorkbook.Worksheets("UNFI Invoice Drop In 2").Cells(Rows.Count, 1).End(xlDown).Offset(2, 0)
End Sub
The bold code is giving me an error of "Application-defined error". I think it is related to the fact that I have .end.offset after the .cells. Is it possible to paste with an offset directly after a copy? What I am missing here?
Any help would be great appreciated!
-tvxl
Bookmarks