Share via

ActiveSheet.Paste into active cell working intermittently

Anonymous
2021-02-16T20:56:03+00:00

Have a macro to copy and paste a shape in the same worksheet to the active cell I have selected.  Very simple.  I added a button for users.  The button and macro were working perfectly fine for weeks, and now the macro only works intermittently and always fails with the Error 1004:  paste method of worksheet class failed and highlights the ActiveSheet.Paste line of code.  When I run the macro without the button, it works 50% of the time. Based on suggestions I tried adding the clear clipboard at the end without success.

Here is the code:

Sub InsertArrow()

    ActiveSheet.Shapes("Elbow Connector 3").Copy

    ActiveSheet.Paste

    Application.CutCopyMode = False

End Sub

Help is appreciated.  Just want to paste the same shape in the selected cell every time the user hits the button.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

  1. OssieMac 48,001 Reputation points Volunteer Moderator
    2021-02-16T23:16:58+00:00

    Yes! I have been able to replicate the error which occurs intermittently as per your description.

    Try the following code. I have not been able to replicate the error with the modifications.

    Sub InsertArrow()

        Application.CutCopyMode = False 'Clear the copy first    

        ActiveSheet.Shapes("Elbow Connector 3").Copy

        DoEvents        'Finish processing before next command

        ActiveSheet.Paste

    End Sub

    Was this answer helpful?

    3 people found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2021-02-18T08:11:13+00:00

    Hi AA625,

    Did you check the above reply from OssieMac? Please update us when you have time.

    Regards,

    Neha

    Was this answer helpful?

    0 comments No comments