+ Reply to Thread
Results 1 to 6 of 6

Paste special error

  1. #1
    Registered User
    Join Date
    11-05-2010
    Location
    Over, There
    MS-Off Ver
    Excel 2016
    Posts
    44

    Paste special error

    I'm having problems with pasting values. The error message I get is "PasteSpecial method of Range class failed." The line that is causing the error the first first PasteSpecial line.


    Please Login or Register  to view this content.
    If I remove the "ThisWorkbook.Unprotect "1234"" line then it will work just fine. Any ideas?
    Last edited by Demon4231; 02-05-2013 at 06:20 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,551

    Re: Paste special error

    Try moving the workbook unprotect before the copy. I suspect that it is cancelling out the copy so you have nothing to paste.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Paste special error

    Hello Demon4231,

    The line of code VBA is pointing to would not cause the error that is reported. Whether the Workbook is protected or not, executing
    Please Login or Register  to view this content.
    will not cause a Paste error. I can not really say what the problem is based on this incomplete code sample. To properly troubleshoot this problem, you should post your workbook.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,551

    Re: Paste special error

    Leith is, of course, correct. I've just done a simple test and putting a workbook protect between the copy and paste doesn't make a difference.

    Sorry, TMS

  5. #5
    Registered User
    Join Date
    11-05-2010
    Location
    Over, There
    MS-Off Ver
    Excel 2016
    Posts
    44

    Re: Paste special error

    Here is the complete section of the code that is being executed.

    Please Login or Register  to view this content.
    I've tried unprotecting the workbook before running the code and it gave the same error. I've also tested a small version of what its doing and it worked fine, I can't see why it wont paste the data. I can paste the data myself and it works without problems.

  6. #6
    Registered User
    Join Date
    11-05-2010
    Location
    Over, There
    MS-Off Ver
    Excel 2016
    Posts
    44

    Re: Paste special error

    Ahhh.... I got it. Moving Thisworkbook.Unprotect "1234" above "If Target.Column = 3 Then", doesn't make sense but now it works.

+ 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