ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   name of calling routine (https://www.excelbanter.com/excel-programming/398536-name-calling-routine.html)

Smallweed

name of calling routine
 
I suspect the answer is "you can't" but does anyone know of a way to return
the name of the routine that's called a function? Failing that, some generic
code that returns the name of the current sub or function? I'm just writing
a universal error routine and it's a pain having to send the calling
routine's name by hand each time.

Bob Umlas

name of calling routine
 
Your latter comment implies you don't like:
Sub RoutineA()
'...
CallFunctionX RealParameter,"RoutineA"
'...
End Sub
Function CallFunctionX(WhatIneed,WhoCalledMe as String)
'...
'WhoCalledMe is the routine who called me in
'...
End Function
Sub AnotherGuy()
'...
CallFunctionX RealParameter,"AnotherGuy"
'...
End Sub

But aside from numbering every line and using the erl (line # function), I
don't know of a way (would be a nice thing to have -- some way to easily to
invoke the Call Stack)

Bob Umlas

"Smallweed" wrote in message
...
I suspect the answer is "you can't" but does anyone know of a way to return
the name of the routine that's called a function? Failing that, some
generic
code that returns the name of the current sub or function? I'm just
writing
a universal error routine and it's a pain having to send the calling
routine's name by hand each time.





All times are GMT +1. The time now is 12:40 PM.

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