0

I'm having trouble copying a range when using a variable to refer to the range being copied. The error i get is:

Run-time error '1004': Application-defined or object-defined error

Sub temp()
Dim Data As Range
Set Data = Range("A1:C1")
Range(Data).Copy Range("E1")
End Sub

There is no problem if i use

Range("A1:C1").Copy Range("E1")

I also tried

Range(Data).Copy Destination:=Range("E1")

I'm using Excel 2010. The above sample is part of a larger body of code. I've isolated the part which generates the error.

Thanks!

1 Answer 1

1

Since Data = Range("A1:C1")

Data.Copy Range("E1")

should work ..

Sign up to request clarification or add additional context in comments.

Comments

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.