Macro must return the name of the button

D

Derek Brussels

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
 
B

Bob Phillips

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

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)
 
P

Puppet_Sock

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
 
C

Chip Pearson

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]...
 
Top