ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet Button Callbacks (https://www.excelbanter.com/excel-programming/271313-worksheet-button-callbacks.html)

Mike Lynch

Worksheet Button Callbacks
 
I have embedded several buttons within different cells of
an Excel worksheet, all of which reference the same
procedure upon clicking. Within the procedure I need to
determine the cell location (BottomRightCell or
TopLeftCell.. I think) of that button. Have searched
knowledge base, Micorsoft help and text books to no avail.

Any thoughts?

Tom Ogilvy

Worksheet Button Callbacks
 
If you mean buttons from the forms toolbar, and if you don't it is far
easier to do this with those buttons, you would use Application.Caller

Sub Button_Click()
sName = Application.Caller
set btn = Activesheet.Buttons(sName)
set rng = btn.TopLeftCell
msgbox "you pressed " & sname & vbnewline & _
"located above cell: " & rng.address
End Sub

Then assign this macro to each of your buttons from the forms toolbar.

Regards,
Tom Ogilvy


"Mike Lynch" wrote in message
...
I have embedded several buttons within different cells of
an Excel worksheet, all of which reference the same
procedure upon clicking. Within the procedure I need to
determine the cell location (BottomRightCell or
TopLeftCell.. I think) of that button. Have searched
knowledge base, Micorsoft help and text books to no avail.

Any thoughts?





All times are GMT +1. The time now is 04:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com