Which Procedure was I call from?

obiron

Active Member
Joined
Jan 22, 2010
Messages
469
Hi guys,

Hopefully a quick question.

I have a sub which is called from a number of different places and I want it to do something different if it is called from one specific place which I would rather not do using parameters.

How can I find out using VBA which procedure called the procedure that I am in. I only need to go back to the immediate parent but if there is generic code that can find all acestors that would also be useful.

Regards

Obiron
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
As far as I know you don't have access to the call-stack programmatically...

Why don't you want to use a parameter? You can use an optional parameter so that you can leave all existing code as-is, only adapt the one specific place where you want to be alerted...
 
Upvote 0
I would go into the editor, find all the calls to that Sub and put a breakpoint on the call...then when the code runs, you can she what area/breakpoint it was called from.
 
Upvote 0

Forum statistics

Threads
1,224,548
Messages
6,179,451
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top