Hi there,
I'm trying to create a macro so that when i highlight a selection i can quickly call the macro to fill the selection with option buttons.
Specifically, I need to be able to separate the group of option buttons as per row so that i'm limited only to the one option button clicked per row and have the button "cell linked" to the first column of the selection of that specific row.
Right now, the code below automatically populates my selection with option buttons, however, i can only have 1 option button clicked at a time. Additionally, i'd like to center and align the option buttons within the selection of buttons.
Thanks for any help
Sub AddOptionButton()
On Error Resume Next
Dim c As Range, myRange As Range
Set myRange = Selection
For Each c In myRange.Cells
ActiveSheet.OptionButtons.Add(c.Left, c.Top, c.Width, c.Height).Select
With Selection
.LinkedCell = c.Address
.Characters.Text = ""
.Name = c.Address
End With
c.Select
With Selection
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, _
Next
myRange.Select
End Sub
I'm trying to create a macro so that when i highlight a selection i can quickly call the macro to fill the selection with option buttons.
Specifically, I need to be able to separate the group of option buttons as per row so that i'm limited only to the one option button clicked per row and have the button "cell linked" to the first column of the selection of that specific row.
Right now, the code below automatically populates my selection with option buttons, however, i can only have 1 option button clicked at a time. Additionally, i'd like to center and align the option buttons within the selection of buttons.
Thanks for any help
Sub AddOptionButton()
On Error Resume Next
Dim c As Range, myRange As Range
Set myRange = Selection
For Each c In myRange.Cells
ActiveSheet.OptionButtons.Add(c.Left, c.Top, c.Width, c.Height).Select
With Selection
.LinkedCell = c.Address
.Characters.Text = ""
.Name = c.Address
End With
c.Select
With Selection
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, _
Next
myRange.Select
End Sub