Home |
Search |
Today's Posts |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
variable or propertie 'name' for self written sub or function
On 15 feb, 14:47, "Chip Pearson" wrote:
Jan, Seehttp://www.cpearson.com/excel/InsertProcedureNames.htmfor code that will automatically insert a CONST statement in to each procedure in a module. The value of the CONST declaration is the name of the procedure that contains it. Once you run this, you can use that constant's name (which you supply) in your error handling message. E.g, ErrHandler: MsgBox "Error: " & CStr(Err.Number) & vbCrLf & _ "Descsrption: " & Err.Description & vbCrLf & _ "In Procedu " & C_PROC_NAME Where C_PROC_NAME is the constant containing the name of the procedure. You choose the name "C_PROC_NAME" (it can be any syntactically correct constant name) and the code automatically insert into each procedure in the module a declaration like Const C_PROC_NAME = "MyProcName" The code on the pagehttp://www.cpearson.com/excel/InsertProcedureNames.htm assume that you are somewhat familiar, at least at a conceptual level, with using VBA code to write more VBA code. This is described in some detail with lots of examples onwww.cpearson.com/excel/vbe.htm -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLCwww.cpearson.com (email address is on the web site) "Jantje" wrote in message oups.com... Hi, i just made a small sub 'logError' that writes the date, time, err.Number and err.Description to a specified worksheet. I also want to write the name of the Sub or Function that caused the error to be raised... Now i have to change the parameter each time i'm using the statement 'logError Date, Time, Err.Number, Err.Description, "name for sub or function" '. Can someone tell me if there's a variable to use that has the name of a self made sub or function? I hope the question is clear enough... Thanks jan- Tekst uit oorspronkelijk bericht niet weergeven - - Tekst uit oorspronkelijk bericht weergeven - Thank you very much Chip, I'll give this one a try... unfortunately i have lots of procedures/functions on worksheet_activate's (and less in modules)... but I think this will come in handy... Greetz, Jan |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how to use the function written in VBA in excel sheet | Excel Discussion (Misc queries) | |||
how to use the function written in VBA in excel sheet | Excel Discussion (Misc queries) | |||
set the bottom propertie of a label | Excel Programming | |||
function to convert whole numbers to written text | Excel Worksheet Functions | |||
Accesing a combobox control via it index propertie in VBA, Is itPossible? | Excel Programming |