0

Why does this work:

Sheets("Sheet1-Orig").Range(Sheets("Sheet1-Orig").Cells(20, 1), Sheets("Sheet1-Orig").Cells(LastRow1, 3)).Copy Destination:=Sheets("3-Orig_Merged").Range("A1")

But this throws up a 1004:

Sheets("Sheet2-Orig").Range(Sheets("Sheet1-Orig").Cells(2, 1), Sheets("Sheet1-Orig").Cells(LastRow2, 3)).Copy Sheets("3-Orig_Merged").Cells(LastRow1 - 18, 1)

Getting Application defined or object defined error. Driving. Me. Nuts...

Thanks!

1
  • 4
    The range and Cell object must be on the same sheet when using cells() inside Range(). Commented Sep 14, 2017 at 14:00

1 Answer 1

1

Even though there are more code lines below, I find it easier to use (and debug later):

With Sheets("Sheet1-Orig")
    .Range(.Cells(20, 1), .Cells(LastRow1, 3)).Copy
End With
Sheets("3-Orig_Merged").Range("A1").PasteSpecial
Sign up to request clarification or add additional context in comments.

3 Comments

The biggest difference between the line that works and the line that doesn't work is that I am pasting to a defined cell (A1) in the line that works, but I am trying to paste to a variable (LastRow1 - 18) in the one that gives the error. The LastRow1 variable has the correct row number (65018) in it. It seems like I can copy using a variable in the range, but I can't paste to one?
@PaulDemay no the issue is that you are referring to two different sheets in the range you are trying to copy.
OMG Scott - duh.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.