Ali Wood
Ali Wood

Reputation: 19

Locating correct run-time error line in VBA

I am getting a runtime error in VBA. I have no error-handling and don't really wish to employ this unless necessary. When I get the run-time error window option to End, Debug or Help, I press Debug. The code editor window opens but in my case it highlights in yellow a line "Load Frm" - which is obviously tells me the error has occurred somewhere in the process of loading the form, but I then have to F8 throughout the whole series of routines which are called until I reach the line that has actually caused the error. This can take a long time! Am I missing something?

Upvotes: 0

Views: 1681

Answers (2)

Zer0Kelvin
Zer0Kelvin

Reputation: 354

I use Google Translator, so there may be some inaccuracies, but I think you understand.

  • In the "Tools" menu of the VBA editor select "Options"
  • Select the "General" tab
  • In the "Error detection" frame select "Abort in class module" and confirm with OK.

Upvotes: 3

baka_toroi
baka_toroi

Reputation: 74

In order to quickly find the line with the actual error you can use the following hot keys:

Shift+F8 when pressed on a line containing a procedure will run the whole procedure (even if it contains several lines inside) and then stop at the next line. If you have stepped inside a procedure you can press Ctrl+Shift+F8 to run everything inside it and go to the next line of the outer procedure. In other words if Sub A at line 5 calls Sub B and you stepped into Sub B, pressing Ctrl+Shift+F8 will run everything in Sub B and return to line 6 of Sub A.

Don't forget about breakpoints, they're very useful.

Upvotes: 0

Related Questions