Setting LinkedCell of individual OptionButton
If you want to add an option button from either toolbar using code, just
turn on the macro recorder and do it manually. This will give you the
specific code you need. You can then generalize it.
Which to use would depend on the functionality you want to achieve.
--
Regards,
Tom Ogilvy
"Angelito Cruz" wrote in message
m...
Thanks Tom!
I figured out how to read the value of the option button on the cell
via this code:
Activesheet.optionbuttons("A3").value
Should I stay away from Optionbuttons from the forms toolbar and just
use the ActiveX equivalent? I am having the hardest time loading the
ActiveX OptionButton via VBA. I am sure it should be easier. Does
anyone have a code snippet I can look at? I will not be posting this
if I saw something that's close to what I am doing via the
Optionbutton from the forms toolbar.
Best Regards,
Angelito
"Tom Ogilvy" wrote in message
...
for optionbuttons from the forms toolbar, all optionbuttons in a group
are
linked to the same cell. The cell then returns the sequence of the the
selected optionbutton.
So what you see is by design.
--
Regards,
Tom Ogilvy
"Angelito Cruz" wrote in message
...
I am creating multiple groupboxes with corresponding optionbuttons
inside it. I am having issues setting the LinkedCell property for
each radio button. For example, if I have 2 OptionButtons, I set the
LinkedCell of the first OptionButton to the right cell, when I add the
second
OptionButton and set it's LinkedCell to the new .Address. The 1st
OptionButton
is set to the new .Address.
Here's the code snippet when adding the OptionButton:
Public Sub InsertOptionButton(ByVal Target As Range, strGroupName As
String)
Dim optBtn As OptionButton
Set WS = Application.ActiveWorkbook.Worksheets("Notes")
With Target
Set optBtn = WS.OptionButtons.Add _
(Top:=.Top + 4, Left:=.Offset(0, 0).Left + 40, Height:=.Height -
2.5, _
Width:=.Width / 2)
optBtn.Caption = ""
optBtn.Name = "opt" & .Address(0, 0)
optBtn.LinkedCell = .Address
optBtn.GroupBox.Name = strGroupName
End With
End sub
Thanks in advance,
Angelito
|