![]() |
How to pass the name of the cmdbutton calling an Excel VBA procedu
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. |
How to pass the name of the cmdbutton calling an Excel VBA procedu
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. |
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. |
All times are GMT +1. The time now is 01:41 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com