+ Reply to Thread
Results 1 to 10 of 10

Modifying Copy - Destination Range throws App Error '1004'

  1. #1
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Modifying Copy - Destination Range throws App Error '1004'

    Greetings,
    I created a working mock up of code I found on the web which consolidates blind survey results for any user ID.
    It worked fine as it stood, but I wanted to modify the code from copying an entire row - to copying just the results across the number of columns that had data in it.

    Please Login or Register  to view this content.
    I have tried lots of permutations of Range properties and Copy/Paste qualifications - but I'm missing something very obvious with the Object variable and I can't figure it out.
    Any help is appreciated. Workbook is attached.

    Mark

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Modifying Copy - Destination Range throws App Error '1004'

    Hey Mark,

    Could it be your are trying to copy a whole row and paste it to a place where the whole row won't fit? I mean there are only so many columns in a Row. You copy these 10000? cells and then go to B7 and try to paste them. They are 7 cells over the limit. Does that make sense?
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Modifying Copy - Destination Range throws App Error '1004'

    I have adjusted the code
    You have number 6 twice on sheet Survey-8-01-10.

  4. #4
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Re: Modifying Copy - Destination Range throws App Error '1004'

    Thanks MarvinP -
    I totally missed that.
    My goal was not to copy everything that might be in that row from A-XFD,
    but to make the Columns range more dynamic by looking “xlToRight”, to find the last data column in that particular “found cell” row.


    Thanks AB33 -
    In this format, “Resize” works only as a static range. If this could be made dynamic, then my problem is solved.
    I’ve had success using this code as a stand alone test:

    Please Login or Register  to view this content.
    Unfortunately, I was unable to incorporate it into the ” Do Loop”.
    Here are four permutations that I attempted and the resulting errors thrown:

    Please Login or Register  to view this content.
    At issue, I believe, it the Object Variable “rFoundCell” and possibly how “ActiveCell” is used in this case. Whether that be its assigned value, returned value or whatever. I don’t have that deep of an understanding of VBA intricacies to debug this problem.

    What mm I missing here?
    Any ideas?

    Thanks--
    Mark

  5. #5
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Re: Modifying Copy - Destination Range throws App Error '1004'

    Thanks MarvinP -
    I totally missed that.
    My goal was not to copy everything that might be in that row from A-XFD,
    but to make the Columns range more dynamic by looking “xlToRight”, to find the last data column in that particular “found cell” row.


    Thanks AB33 -
    In this format, “Resize” works only as a static range. If this could be made dynamic, then my problem is solved.
    I’ve had success using this code as a stand alone test:

    Please Login or Register  to view this content.
    Unfortunately, I was unable to incorporate it into the ” Do Loop”.
    Here are four permutations that I attempted and the resulting errors thrown:

    Please Login or Register  to view this content.
    At issue, I believe, it the Object Variable “rFoundCell” and possibly how “ActiveCell” is used in this case. Whether that be its assigned value, returned value or whatever. I don’t have that deep of an understanding of VBA intricacies to debug this problem.

    What am I missing here?
    Any ideas?

    Thanks--
    Mark

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Modifying Copy - Destination Range throws App Error '1004'

    There are a couple of ways to make the range dynamic. If you have a header in each sheet, this option is the easiest one. Try it

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Modifying Copy - Destination Range throws App Error '1004'

    Maybe:

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Re: Modifying Copy - Destination Range throws App Error '1004'

    Thanks AB33!
    I had thought of trying something to that nature but just couldn't figure out where to begin.
    YourCode:
    Please Login or Register  to view this content.
    Question: Why would the ActiveCell code work as a stand alone test, but not with an object variable?
    Any ideas?


    Hi John-
    I tried implementing you idea w/o success.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

    This is an interesting puzzle that requires more experimentation.

    I appreciate your quick responses and helpful ideas.
    Any further input is most welcomed.

    Mark

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Modifying Copy - Destination Range throws App Error '1004'

    Mark,
    Question: Why would the ActiveCell code work as a stand alone test, but not with an object variable?
    Any ideas?
    I have not used any word "Active". Your code was good, except I have added a single line.
    It is terrible idea to use ActiveCell. ActiveCell could be anywhere the cursor is. What happens if I click any in cell while the code is running, it becomes an active cell, so avoid using it.
    Your code was very good, just remove active

  10. #10
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Re: Modifying Copy - Destination Range throws App Error '1004'

    Hi AB33
    Quote Originally Posted by AB33 View Post
    Mark,
    Question: Why would the ActiveCell code work as a stand alone test, but not with an object variable?
    Any ideas?
    Now that I think about it, the standalone test was one selected cell. Once the routine finished, that was it.
    Perhaps, in order to return multiple rFoundCells, each instance of the ActiveCell must be activated or selected (?) Rather like - if rFoundCell is true,then ActiveCell.Select or Activate (or whatever) - as in this piece of code:
    (Just guessing here.)

    Please Login or Register  to view this content.
    Either way, your line of code was enlightening and solved my problem nicely.
    Thanks again.

    Cheers!
    Last edited by max57; 06-22-2016 at 02:55 PM.

+ 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] SlicerCache Exists But SlicerItems Throws 1004 Error
    By goss in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 10-24-2013, 03:59 PM
  2. Copy cell values with 'if' statement throws error
    By Mayweed in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-19-2011, 10:27 PM
  3. Replies: 2
    Last Post: 12-02-2010, 03:46 AM
  4. Run-time error '1004': copy methos of range class failed
    By fungus in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 11-11-2010, 05:03 PM
  5. Copy range to worksheet - 1004 Run Time error
    By inky in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-10-2008, 07:39 AM
  6. Run-time error '1004' with Range and copy
    By Mbrolass in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-04-2007, 04:20 PM
  7. workbook.open throws 1004 error
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-03-2006, 06:45 PM

Tags for this Thread

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