I'm currently working on a sheet that has a graph displaying the cost of several different solutions to a problem. Underneath this graph is a series of buttons that the user can press to get more details about a certain solution. The amount of solutions is variable, and, as such, so is the amount of buttons.
I create the buttons using the code below: (nested within a for-loop to generate the appropriate amount of buttons)
ActiveSheet.Buttons.Add(xpos, 462, width, height).Select
Selection.Caption = [caption, long and irrelevant]
Selection.name = "OptieBtn" & Str(count)
Selection.OnAction = "Sheet7.SelectOpt"
xpos = xpos + xspacing
What I want is to somehow pass a parameter (count, in this case) to the 'SelectOpt' sub, so I know what option the user has selected (if it's somehow possible to get the object that triggered the sub, that would probably work too).
Alternatively, it would be acceptable to set the "OnAction" property dynamically so that each button activates a different sub. I tried concatenating a number to the "OnAction" string, but excel doesn't seem to allow that.
How can this be achieved?
Bookmarks