Retrieving name from command button on Worksheet
I'm using Excel 2000 under win2K and have several command buttons on a
worksheet and assigned the same macro to them. In the macro I want to find out WHAT button has been clicked (extracting a number I attached to a name to privide as parameter in a function). I don't want to create a bunch of macro's just to identify each command button separately. How do I do that? |
Retrieving name from command button on Worksheet
If you are using buttons from the Forms toolbar then
"Application.Caller" returns a string with the button name. Extracting a single digit suffix from the button name could work like this... Sub CommonSubCalledByAllButtons() Select Case Right$(Application.Caller, 1) Case "1" 'do something Case "2" 'don't do something Case "3" 'do something else Case "4" 'have lunch End Select End Sub -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware wrote in message oups.com... I'm using Excel 2000 under win2K and have several command buttons on a worksheet and assigned the same macro to them. In the macro I want to find out WHAT button has been clicked (extracting a number I attached to a name to privide as parameter in a function). I don't want to create a bunch of macro's just to identify each command button separately. How do I do that? |
All times are GMT +1. The time now is 10:09 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com