+ Reply to Thread
Results 1 to 5 of 5

problem with error handling

  1. #1
    Registered User
    Join Date
    11-21-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    40

    problem with error handling

    Sub Paste_Value_On_Selected_Cells()
    Hi, i have a code as follows:

    Please Login or Register  to view this content.
    First part of the code will allow users to, for eg, select the filtered cells (A2, A3, A6, A24, A35) and paste the values onto it. This works well.
    Secondly, when errors occur, a popup of my pre-entered text should appear. This part fails.
    For eg, when I copied values from 6 consecutive cells in a column, and paste it on the selected, visible and filtered, 5 cells, the following error appears:
    Run-time error ‘1004’:
    PasteSpecial method of Range class failed
    If the code worked correctly, it should have replaced this message with a popup message that I had pre-entered. Anyone can assist on this?

  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,243

    Re: problem with error handling

    You have to place the error trap before the code, not after it.


    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
    Registered User
    Join Date
    11-21-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    40

    Red face Re: problem with error handling

    Yes, I tried but it still fails..


    Please Login or Register  to view this content.

  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,243

    Re: problem with error handling

    No, not quite what I meant:

    Please Login or Register  to view this content.

    Regards, TMS

  5. #5
    Registered User
    Join Date
    11-21-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: problem with error handling

    Thanks, im outside now and will try it out once I'm home.

+ 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