Macro must return the name of the button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,

I want to a macro to display the name of the button (or object) from where I
am calling that macro. Anyone an idea?

thanks,
Derek
 
What sort of button (userform, worksheet forms, worksheet control toolbox)?

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)
 
Derek said:
I want to a macro to display the name of the button (or object) from where I
am calling that macro. Anyone an idea?

Why do you need this? Don't you know what button you
have attached the code to?

If you are trying to have the same code attached to different
buttons, and still have it do different work for different buttons,
then you have to put a layer between. Like so.

Button1 -> Sub1 -> MainSub
Button2 -> Sub2 -> MainSub
....
ButtonN -> SubN -> MainSub

So, each of these small functions is attached to only one button,
knows what button it is attached to, and picks out the args to
call MainSub with so it does the right work.
Socks
 
If the button or control is from the Forms command bar (not the
Controls command bar) you can use Application.Caller to get the
name of the control.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


in message
news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top