copy and pasting error

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

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

Copy and pasting error from sheet1 to sheet2 | Excel forum

resolvedResolved · Medium Priority · Version 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:

Working with 3D formulas

You can only use fill-down if you remove $ for Absolute References.

View all Excel hints and tips


Server loaded in 0.07 secs.