View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
LPS LPS is offline
external usenet poster
 
Posts: 108
Default How to pass the name of the cmdbutton calling an Excel VBA pro

Excellent, it works!

Thank you --- I would have never thought of referring to Shapes.

---------

"Ron de Bruin" wrote:

Hi LPS

Use forms buttons and attach this macro to all of them

Sub test()
MsgBox ActiveSheet.Shapes(Application.Caller).Name
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl



"LPS" wrote in message ...
I would like to have multiple command buttons call a single procedure and
that procedure displays a msgbox that shows the name of the button which
called it.

Can anyone help with the correct code? I've tried several things that have
not worked. The only solution I came up with is having the 'click' method of
the buttons call the single procedure and pass the name as a variable. the
problem with this if I expland the scenario to 20+ command buttons, there is
a lot of excess 'click' method code which seems redundant.

Thanks in advance for any help.