+ Reply to Thread
Results 1 to 4 of 4

Code works but gives error message

  1. #1
    Forum Contributor
    Join Date
    04-07-2009
    Location
    Tasmania, Australia
    MS-Off Ver
    Excel 2003
    Posts
    158

    Code works but gives error message

    Can someone please tell me why this code works, but gives an error 1004 message "Copy method of Range class failed"? Debug highlights the penultimate line.

    I have been searching for days and changed the offending code from "select" to what seems to be accepted as more efficient, but with the same result.

    Any help appreciated.

    Please Login or Register  to view this content.
    Steve W.
    Vba is my hobby, racing the means.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Code works but gives error message

    The destination is not fully qualified. Which workbook are you pasting to? Specify workbook, worksheet and range, just like you did in the first part of the statement.

    In general, I'd use dim statements at the beginning of the code to define source and target workbooks and worksheets, then set them to the required workbooks and sheets. Then the code will be so much easier to write (and read).

  3. #3
    Forum Contributor
    Join Date
    04-07-2009
    Location
    Tasmania, Australia
    MS-Off Ver
    Excel 2003
    Posts
    158

    Re: Code works but gives error message

    Thanks for your reply. The first part of your answer didn't work , so I'm working my way through part 2 and will post back here when I either work it out or give up. Hopefully this afternoon.

    Steve

  4. #4
    Forum Contributor
    Join Date
    04-07-2009
    Location
    Tasmania, Australia
    MS-Off Ver
    Excel 2003
    Posts
    158

    Re: Code works but gives error message

    It appears that the multiple groups of columns to be copied is the cause of the problem. Even with Dim statements, until I copied each group of Columns separately, I was getting the error message - despite it actually doing what I wanted.

    Anyway, thanks teylyn for your help. If you (or anybody?) can show me how to copy all the columns in one step, I'd appreciate it, but the code works as it is, so I'm happy. Will close the thread tomorrow if no replies.



    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] .Match with On Error: On Error Resume Next works. On Error GoTo only works once. Err.Clear
    By Doc.AElstein in forum Excel - New Users/Basics
    Replies: 28
    Last Post: 03-16-2015, 12:55 PM
  2. [SOLVED] Code Gives error if I run it from Module but works fine when run it from This Worksheet
    By VKS in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-17-2013, 01:18 PM
  3. [SOLVED] run time error 91 - but code works in another spreadsheet ?
    By pmasrich in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2013, 07:32 AM
  4. [SOLVED] Error when trying to use code that works in Excel 2007 to 2010
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-23-2012, 10:38 AM
  5. [SOLVED] Excel produces Error when the code works
    By WadeLair in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-09-2012, 11:15 PM
  6. Getting this code to work on MAC (ERROR 68) - works fine on Windows
    By LT1511 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-30-2012, 11:09 PM
  7. code works sometimes, not always, error 424
    By Hein in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-04-2010, 08:59 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1