msgbartop
Just another WordPress site
msgbarbottom

28 Jan 09 VBA Error Handling with line numbers

Sometimes it is easier to find an error if we know the code line where the error occurred. I have a method to show this in an error message.This is a light version of my error handler and focuses only to the line number of the error.There is a variable called “erl” which contains the line number of the error, so we can use it in the error message:

MsgBox Err.Number & " - " & Erl & " - " Err.Description

But this will show 0 instead of the line number if we didn’t put numbers at the beginning of the rows.Dick Kusleika wrote about the MZ Tools, and MZTools is a great tool for this too.There is an “add line number” icon on the toolbar which made the line numbering in my stead.

addlinenr VBA Error Handling with line numbers

Add Line Number Icon

Voila, it is done, and we can use it.