In the following vba code from Excel 365 I am creating a number of radio buttons. I cannot seem to assign them to a group for later use in code.
I have tried using .Group and .OptionButtonGroup but neither come up in intellisense. Its like the Microsoft Forms 2.0 Object Library is not referenced, but it is. What am I missing?
TIA.
Private Sub AddProductLine()
Dim optBtn As control
Dim c As control
Dim theTop, theWidth As Double
Dim i As Integer
Dim theProductList As Variant
theProductList = GetProductNames '-----GETTING PRODUCT LINES FROM EXCEL SHEET
theTop = 10 '-----SETTING TOP OF FIRST BUTTON IN FRAME
theWidth = 50 '-----SETTING WIDTH OF ALL THE RADIO BUTTONS
'-------------------ADDING THE RADIO BUTTONS TO THE FRAME PRODUCT LIST
For i = 1 To UBound(theProductList)
Set optBtn = ProductFrame.Controls.Add("Forms.OptionButton.1", theProductList(i, 1), True)
With optBtn
.Caption = theProductList(i, 1)
.Width = theWidth
.Top = theTop
.Left = 12
End With
theTop = theTop + 17.5
Next i
ProductFrame.Height = theTop + 15
Me.Controls.Item("GAP").Value = True
End Sub
I have tried using .Group and .OptionButtonGroup but neither come up in intellisense. Its like the Microsoft Forms 2.0 Object Library is not referenced, but it is. What am I missing?
TIA.
Private Sub AddProductLine()
Dim optBtn As control
Dim c As control
Dim theTop, theWidth As Double
Dim i As Integer
Dim theProductList As Variant
theProductList = GetProductNames '-----GETTING PRODUCT LINES FROM EXCEL SHEET
theTop = 10 '-----SETTING TOP OF FIRST BUTTON IN FRAME
theWidth = 50 '-----SETTING WIDTH OF ALL THE RADIO BUTTONS
'-------------------ADDING THE RADIO BUTTONS TO THE FRAME PRODUCT LIST
For i = 1 To UBound(theProductList)
Set optBtn = ProductFrame.Controls.Add("Forms.OptionButton.1", theProductList(i, 1), True)
With optBtn
.Caption = theProductList(i, 1)
.Width = theWidth
.Top = theTop
.Left = 12
End With
theTop = theTop + 17.5
Next i
ProductFrame.Height = theTop + 15
Me.Controls.Item("GAP").Value = True
End Sub