Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

copy and pasting error

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Copy and pasting error from sheet1 to sheet2

Copy and pasting error from sheet1 to sheet2

ResolvedVersion 2007

Jack has attended:
Excel Advanced course
Excel VBA Intro Intermediate course
Excel VBA Advanced course

Copy and pasting error from sheet1 to sheet2

Hi there,

Very quick one, trying to copy from sheet1 to sheet2 but vba is throwing up runtime error 1004 object defined error:

Sheets("sheet1").Range("A14:C14", Range("A14:C14").End(xlDown)).Copy Destination:=Sheets("sheet2").Range("A3")

if i remove this element the code works fine, "Range("A14:C14").End(xlDown)".

i can break the code down into seperate lines to make it work but trying to be efficient.

Thanks in advance..

Jack

RE: Copy and pasting error from sheet1 to sheet2

Hi Jack, thanks for your query. A couple of things come to mind. First of all have you tried the code on different versions of Windows/Office. Some run time errors of this nature are triggered by differences in the object model, but usually this is because you're trying to use a method not introduced until later version of Excel. Have a read through this thread for more information:

http://www.excelforum.com/excel-programming/507929-runtime-error-1004-pastespecial-method-of-range-class-failed.html

However, I rebuilt your line of code and got it to run...twice, before the run time error kicked in. I tried clearing the clipboard, which didn't work and after some research found this article on the MSDN:

http://support.microsoft.com/kb/905164

That's about filtered data, but still relevant I believe. I think in this case you need to sacrifice elegance for functionality!

Hope this helps,

Anthony

Fri 1 Oct 2010: Automatically marked as resolved.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Calculate age or service

The DATEDIF() function in Excel calculates the number of days, months, or years between two dates. So, this function makes it easy to calculate a person's age. To try this tip:

In a blank worksheet, type the birth date in cell A1, using slashes to separate day, month, and year.
In cell A2, type =DATEDIF(A1,TODAY(),"y") and press ENTER.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.