+ Reply to Thread
Results 1 to 3 of 3

Paste method of worksheet class failed

  1. #1
    Registered User
    Join Date
    08-17-2007
    Posts
    2

    Paste method of worksheet class failed

    Hi,

    I've seen several references to similar problems online, but none of them seem to match exactly what I'm experiencing, so:

    I've got two workbooks, and I'm copying data from one to another. The user selects one or more cells in a single column in one workbook, runs my macro and the data is copied into a certain place in the other one. By the time the code hits a problem, the cells have been copied to the clipboard, the other workbook has been activated, and I'm about to select a blank cell at the bottom of the ActiveSheet where I want to paste the data in one chunk, ready to move it into the appropriate places. Here's the problem code:

    Please Login or Register  to view this content.
    This works fine if they select just one cell, but if they select two or more, the code fails on the ActiveSheet.Paste line, with the error message 'Paste method of worksheet class failed'. Oddly, the data are pasted in successfully before the error message is thrown. If I stop the code before the problem line and run a Paste manually, it works fine. Oh, and the error is still thrown if I select more than one cell before pasting.

    Suggestions welcomed, thanks. I'm not an expert on VBScript, so keep 'em simple, please!

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    You could try adding this at the start og the macro

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Registered User
    Join Date
    08-17-2007
    Posts
    2
    Ha, thanks for that, mudraker. Putting in the On Error line worked (can't believe I didn't think of that), although it's still a *little* odd (later in the code there's a set of 'Cut' lines which are failing to Cut, just doing a Copy instead). But it works. Not eactly an explanation, but it fixes my problem!

+ 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