Worksheet Button Callbacks

  • Thread starter Thread starter Mike Lynch
  • Start date Start date
M

Mike Lynch

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?
 
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
 
Back
Top