+ Reply to Thread
Results 1 to 7 of 7

Run time error 13 when deleting more than one cell with Worksheet_Change event macro

  1. #1
    Registered User
    Join Date
    05-11-2008
    MS-Off Ver
    2010
    Posts
    91

    Run time error 13 when deleting more than one cell with Worksheet_Change event macro

    So I created a Worksheet_Change event macro to automatically paste down formulas in the same row once anything in cells A3 or higher have changed. However I know there will be times when the end user will input data incorrectly and will want to delete that row and start over. My problem is everytime I try to delete all the data in say row 3 for example, I get a Run-time Error 13 message. Here's my code and I've also attached a sample worksheet. What am I missing? TIA.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by som3on3_10; 07-22-2010 at 12:29 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Run time error 13 when deleting more than one cell with Worksheet_Change event ma

    Maybe add this at the beginning:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    05-11-2008
    MS-Off Ver
    2010
    Posts
    91

    Re: Run time error 13 when deleting more than one cell with Worksheet_Change event ma

    JBeaucaire,

    That worked perfectly, thanks for your help. I did have a question though. I noticed that when I put in the "If" code that you suggested, I didn't have to finish it with a "End If" like how I normally do with "If" codes. Or is it all part of the same "If" code? Just trying to understand the logic.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,021

    Re: Run time error 13 when deleting more than one cell with Worksheet_Change event ma

    Yes, if the If ... Then ... statement only occupies one line, then you don't need an End If.
    Incidentally your code can be streamlined to remove all that unnecessary selecting of cells - I will post a revised version when back at a PC.
    Everyone who confuses correlation and causation ends up dead.

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,021

    Re: Run time error 13 when deleting more than one cell with Worksheet_Change event ma

    Suggested version:
    Please Login or Register  to view this content.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Run time error 13 when deleting more than one cell with Worksheet_Change event ma

    Good stuff RS.

    ==========
    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  7. #7
    Registered User
    Join Date
    05-11-2008
    MS-Off Ver
    2010
    Posts
    91

    Re: Run time error 13 when deleting more than one cell with Worksheet_Change event ma

    Great, thanks for all the help and info. Much appreciated.

+ 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