+ Reply to Thread
Results 1 to 11 of 11

Cut and Paste Code Error

  1. #1
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Cut and Paste Code Error

    Hi all,

    I am working on the following code:

    Please Login or Register  to view this content.
    It is failing at the line:

    Please Login or Register  to view this content.
    Can someone please help me fix it.

    Thank you,
    Gos-C
    Last edited by Gos-C; 11-21-2010 at 02:25 PM.
    Using Excel 2010 & Windows 10
    "It is better to be prepared for an opportunity and not have one than to have an opportunity and not be prepared."

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: Cut and Paste Code Error

    Is there anything below A13? if not, you will receive an error.

  3. #3
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Re: Cut and Paste Code Error

    Hi davesexcel,

    Yes, there is data down to row 50.

    Here is the error message:

    Run-time error
    Application-defined or object-defined error
    Last edited by Gos-C; 11-20-2010 at 12:07 PM.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: Cut and Paste Code Error

    I don't get the error, have you a test file I can enter into the InputBox, I have the first part of the code commented because I can't use it.

  5. #5
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Re: Cut and Paste Code Error

    Here is a sample of the file. Thank you.

    Gos-C

  6. #6
    Registered User
    Join Date
    05-27-2010
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003 (Work) 2007 (Home)
    Posts
    20

    Re: Cut and Paste Code Error

    is this the problem?

    Please Login or Register  to view this content.
    there is no paste code
    Last edited by lisa_jd; 11-21-2010 at 05:59 AM.

  7. #7
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Re: Cut and Paste Code Error

    Hi lisa_jd & davesexcel,

    I think the problem is with the LastRow because I did a Debug.Print LastRow and I got 1.

    Can you please advise.

    Thank you,
    Gos-C

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: Cut and Paste Code Error

    Here is one way
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Re: Cut and Paste Code Error

    Hi davesexcel,

    I got the same error. Could it be that the LastRow line is not pointing to the correct sheet?


    Here are some interesting results, which may help you figure out the problem:

    Debug.Print ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row

    =49

    Debug.Print ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row - 13

    =36

    Debug.Print LastRow

    =1

    This makes me suspect that LastRow in the code is not for the correct sheet, Sname, as it should. If so, how do I fix it.

    Thank you,
    Gos-C

  10. #10
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: Cut and Paste Code Error

    how about.

    Please Login or Register  to view this content.
    How fast this could be answered if you supplied a small example.

  11. #11
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Thumbs up Re: Cut and Paste Code Error

    davesexcel,

    That's it!

    Please Login or Register  to view this content.

    Now it's working.

    Thank you kindly,
    Gos-C

+ 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