0

So I created a code which opens each file in a folder and copy's data into the workbook the code is running from. I used Row.count to paste these items.

ActiveWorkbook.Worksheets("Temped Out").Range("B2:B30").Copy _
ThisWorkbook.Worksheets("Temp Out Count ").Range("A" & Rows.Count).End(xlUp).Offset(1, 0) 

However, When trying to paste Columns A and B from this sheet into the first available columns on another sheet I get an error. Currently the Error is: Application-defined or object-defined error but I've played around with it where it says the selected area is not large enough or I've gotten it to paste in Columns B and C on the other sheet but it won't move over to D and E when I run it again. This is my current code. How should I edit this code?

ThisWorkbook.Activate 'Need to activate notebook first before sheet can be selected
ThisWorkbook.Worksheets("Temp Out Count ").Select 'Sheet needs to be selected before columns can be selected
Columns("A:B").Copy ThisWorkbook.Worksheets("Running Count Data").Columns(1, Columns.Count).End(xlToLeft).Offset(1, 0)
braX
  • 11,506
  • 5
  • 20
  • 33
  • You've got the offset arguments off. Change to `.Offset(0,1)`. The first argument is the row offset, and the second is the column offset. – BigBen Jul 28 '20 at 19:56
  • Also see [this](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba): no need to `Select` or `Activate` at all. – BigBen Jul 28 '20 at 19:56

0 Answers0