Suppose I have two subroutines - Sub1 and Sub2 - that both call a third subroutine - Sub3. Is there some code I can put inside Sub3 so that when it's running, it knows whether it was called by Sub1 or Sub2?
Suppose I have two subroutines - Sub1 and Sub2 - that both call a third subroutine - Sub3. Is there some code I can put inside Sub3 so that when it's running, it knows whether it was called by Sub1 or Sub2?
this might work
![]()
Please Login or Register to view this content.
Ernest
Please consider adding a * if I helped
Nothing drives me crazy - I'm always close enough to walk....
There is no built-in way in VBA for a Sub to discover which Sub called it. The method judgeh59 describes is pretty much all you can do, although the syntax isn't correct.
However, I would like to convince you that this is a poor design practice. A Sub should have inputs, outputs, and a function to perform. It should not care who called it to perform this function. Can you provide a little more information about your code structure, and why Sub3 needs to know who called it? There might be alternatives that result in a better design.![]()
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks