+ Reply to Thread
Results 1 to 9 of 9

Paste values code returns "0"

  1. #1
    Registered User
    Join Date
    12-09-2008
    Location
    Canada
    Posts
    79

    Paste values code returns "0"

    Hello,

    I have a simple code that opens 2 workbooks and then copies and pastes a cell from one to the other. The cell that's being copied is a formula by the way.

    My problem is that the copy and paste keeps returning a "0" value, instead of the correct number. I am thinking it's probably because the file from which it is copied is very large and because the operation barely takes a second, it doesn't allow it enough time for the formula int he cell that is being copied to calculate the value.

    Any suggestions are appreciate.

    Please Login or Register  to view this content.
    Last edited by GeorgY; 11-11-2009 at 07:32 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Paste values code returns "0"

    Have to tried setting a breakpoint after the Selection.Copy line, and see (from the marching ants) if you're copying the right cell?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    12-09-2008
    Location
    Canada
    Posts
    79

    Re: Paste values code returns "0"

    Quote Originally Posted by shg View Post
    Have to tried setting a breakpoint after the Selection.Copy line, and see (from the marching ants) if you're copying the right cell?
    Yes, I have. It's the right cell.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Paste values code returns "0"

    The operative change below is that the copied cell is calculated before being copied. The debug lines will allow you to verify that.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-09-2008
    Location
    Canada
    Posts
    79

    Re: Paste values code returns "0"

    thanks for that
    i tried it and verified that it is copying and pasting from/to the right places

    however, the pasted cell is still showing up as "0" instead of the number that is being copied

    any other ideas?

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Paste values code returns "0"

    What is the cell value following the copy -- where the first Stop statement appears, Georg?

  7. #7
    Registered User
    Join Date
    12-09-2008
    Location
    Canada
    Posts
    79

    Re: Paste values code returns "0"

    Please ignore that last message. I fixed the problem.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Paste values code returns "0"

    Are you gonna share what the problem was?

  9. #9
    Registered User
    Join Date
    12-09-2008
    Location
    Canada
    Posts
    79

    Re: Paste values code returns "0"

    There were hidden rows which made it look as if the right cell was being copied, but as a matter of fact, it was another (one of the hidden ones). I used your break code a few times until I saw it.

    Thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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