View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Macro relative to button position

if you are using buttons from the forms toolbar

Public ButtonClick()
Dim sName as String
Dim btn as Button
Dim rng as Range
sName = Application.Caller
set btn = Activesheet.Buttons(sName)
set rng = btn.TopLeftCell.Offset(0,1)
if rng.Value = "X" then
rng.clearcontents
else
rng.Value = "X"
end if
End Sub

--
Regards,
Tom Ogilvy

wesandem wrote in message
...
Is there a way to make a macro relative to a button position? I want to
have a macro input a set value into a cell that is beside the button.
The sheet I am desiring has hundreds of buttons that all do the same
exact thing - place an "X" into the cell beside the button - I don't
feel like writing hundreds of individual macros, so I am hoping there
is a way to make the action relative to the button, not absolute or
relative to the currently selected cell, which are the only two options
i know of.
Please help - this is driving me nuts! THANKS!


---
Message posted from http://www.ExcelForum.com/