+ Reply to Thread
Results 1 to 10 of 10

Macro fails at pasting (Run-time error '1004' Paste method fail)

  1. #1
    Registered User
    Join Date
    04-07-2010
    Location
    Antwerp, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    5

    Question Macro fails at pasting (Run-time error '1004' Paste method fail)

    First off, let me start off by saying that I'm not the creator of the macro, so I don't know all the details. I have been given the file and asked to help find a solution, where best to go to ask for help than here right!
    The error is "Run-time error '1004' Paste method of Worksheet class failed"
    The macro used to work in excel 2003 if I remember correctly, but definetly doesn't in the 2007 version because of this error. I've done some backtracking down the forums and research but still feel rather hopeless, so I'll post the macro in here, should give you sufficient information.

    Please Login or Register  to view this content.
    Help much appreciated!
    Last edited by Richard Buttrey; 04-07-2010 at 06:57 AM.

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Macro fails at pasting (Run-time error '1004' Paste method fail)

    Please wrap your code in code tags, before the moderators get you...

    Forum rules

    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # button at the top of the post window. If you are editing an existing post, press Go Advanced to see the # button.
    Cheers

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro fails at pasting (Run-time error '1004' Paste method fail)

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    Since this is your first post I have done it for you but please remember in the future.

    Regards
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro fails at pasting (Run-time error '1004' Paste method fail)

    Hi,

    You need to move the

    Please Login or Register  to view this content.
    code after your ActiveSheet.Paste line.

    However better still avoid all the .Selects and address the objects directly. Use code like the following - note this is not complete I show you merely as an example.


    Please Login or Register  to view this content.
    HTH

  5. #5
    Registered User
    Join Date
    04-07-2010
    Location
    Antwerp, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Macro fails at pasting (Run-time error '1004' Paste method fail)

    Allright, I'll give that a try, and the code mistake won't happen again, sorry!

  6. #6
    Registered User
    Join Date
    04-07-2010
    Location
    Antwerp, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Macro fails at pasting (Run-time error '1004' Paste method fail)

    Well I moved the
    Please Login or Register  to view this content.
    after the ActiveSheet.Paste line.

    And that seemed to resolve the paste issue.
    But after that, further down the macro, I get the same error, but for pastespecial. Thoughts?

    Sub Danke6()
    '
    ' Danke6 Macro
    ' Macro recorded 27-05-2005 by Ernest Smeets
    '

    '
    ActiveSheet.Unprotect
    Selection.Font.ColorIndex = 3
    Selection.Copy
    Range("AG20:AM20").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Selection.Clear
    Range("Z20:AV22").Select
    Selection.PrintOut Copies:=2
    Range("Z20:AT20").Select
    Selection.Copy
    Sheets("Liste").Select
    Application.CutCopyMode = False
    ActiveSheet.Unprotect
    Range("A4").Select
    ActiveSheet.PasteSpecial Format:="VALU", Link:=False, DisplayAsIcon:= _
    False

    Range("V4").Select
    ActiveCell.FormulaR1C1 = "=NOW()"
    Range("V5").Select
    Selection.Copy
    Range("V4").Select
    Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Application.CutCopyMode = False
    Selection.Copy
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Range("W5").Select
    Application.CutCopyMode = False
    Selection.AutoFill Destination:=Range("W4:W5"), Type:=xlFillDefault
    Range("W4:W5").Select
    Range("A4").Select
    Selection.EntireRow.Insert
    Range("A4").Select
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    Sheets("TICKET").Select
    Range("Z20").Select
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    ActiveWorkbook.Save
    End Sub

  7. #7
    Registered User
    Join Date
    04-07-2010
    Location
    Antwerp, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Macro fails at pasting (Run-time error '1004' Paste method fail)

    Bump no response

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,717

    Re: Macro fails at pasting (Run-time error '1004' Paste method fail)

    Same thing - you have a line that sets Application.Cutcopymode = False a few lines before your PasteSpecial.
    Everyone who confuses correlation and causation ends up dead.

  9. #9
    Registered User
    Join Date
    04-07-2010
    Location
    Antwerp, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Macro fails at pasting (Run-time error '1004' Paste method fail)

    Quote Originally Posted by romperstomper View Post
    Same thing - you have a line that sets Application.Cutcopymode = False a few lines before your PasteSpecial.
    So I'm supposed to fit that code in after the pastespecial then?

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro fails at pasting (Run-time error '1004' Paste method fail)

    Quote Originally Posted by SergioS View Post
    So I'm supposed to fit that code in after the pastespecial then?
    Hi,

    Yes. Otherwise the .CutCopyMode = False will cause you to lose the range you're copying.

    Rgds

+ 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