Forum Discussion
heylookitsme
Jan 29, 2021Iron Contributor
Excel VBA Reference Line Where Error Occurs
I have searched the web over to find out how I can set my error handler to reference the line in the code that errors. I currently have it set so my error handler sends me an email with the details o...
heylookitsme
Jan 29, 2021Iron Contributor
That information is not exposed to the programmer when an error occurs.
It should be. That would provide a great way for programmers to get specific error details which would help them debug errors much faster. I see this having huge potential if it were available.
It should be. That would provide a great way for programmers to get specific error details which would help them debug errors much faster. I see this having huge potential if it were available.
jlanstead
Feb 14, 2023Copper Contributor
https://www.fmsinc.com/free/newtips/VBA/ErrorHandling/LineNumber.html
First, you must number the lines and then reference the line number that causes the error using ERL.
You can find an example in the link above.