Consulting

Results 1 to 2 of 2

Thread: Catching fatal VBA errors

  1. #1

    Catching fatal VBA errors

    I've a sheet that receives data from another program and now and then it fatally crashes, I'm thinking it's due to some data not being present that it's expecting. It's receives betting data and once a non runner is declared I guess price data for it is missing. I'm not sure where it's falling over though as it just freezes and has to be shut down and reopened. I have on error resume next in a few places but still crashes.

    Is there any code I can add to the overall sheet that would catch where the sheet is falling over rather than trying to try and pin which code in all the various modules is crashing. It currently fires everything off using a Worksheet_Change event to call routines in various modules at te moment.

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    First remove or comment out all On Error and other Error handlers.
    Second in the VBA Menu >> Tools>> Options>> General Tab, Set "Break on all Errors"

    Make sure that "Option Explicit" is at the top of all modules. Only then, Compile the code. Fix all mistakes that finds.

    When receiving data from the betting program, (Which one?) and it breaks, Set some Watches to see what values various objects, variables, etc contain. Right Click the item you want to Watch. You can also hover the mouse over many words to see that value.

    If you right click the vertical border on the left side of the Code Pane, you can set the next statement to run, which means you can rerun the code from there... Handy to check edited code during the same process. Or skip some code, (not recommended) depending where you set the Next line to run.

    You can also set Break Points, which will pause the code at that line. Pressing F8 will run the code one line at a time. Pressing F5 will run the code until it meets a BreakPoint, or fails... or finishes.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •