ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error Handling (https://www.excelbanter.com/excel-programming/333400-error-handling.html)

Billy Boone

Error Handling
 
I'm relatively new to Excel programming (but not programming in general) -
so I have written some macros and part of the error handling - I wanted to
display an error message - including the macro that had the problem. I was
expecting to use Err.Source - but that returns Microsoft Excel. Any way to
get the source macro function name (short of hard coding a string)?

BBB



Rob Bovey

Error Handling
 
"Billy Boone" wrote in message
news:dCaxe.107311$_o.44354@attbi_s71...
I'm relatively new to Excel programming (but not programming in general) -
so I have written some macros and part of the error handling - I wanted to
display an error message - including the macro that had the problem. I
was
expecting to use Err.Source - but that returns Microsoft Excel. Any way
to
get the source macro function name (short of hard coding a string)?


Hi Billy,

Unfortunately, hard-coding the macro name in a string is the only way to
know where the error occurred. VBA does support line numbering, and there
are utilities out there that will line number your code so you can retrieve
the number of the line of code that caused the error, but I've personally
found that line numbering is a lot more trouble than it's worth.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm




All times are GMT +1. The time now is 07:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com