Can someone tell me how to group these non-ActiveX option buttons?

AskMyDog

New Member
Joined
Nov 13, 2015
Messages
16
I can't for the life of me figure out how to group non-activeX option buttons. I want to be able to group all the buttons in the "for j to Opt_Btn_count" loop.

Does anyone have any idea how to do this?

Code:
Sub Add_XOptionBtns()
Dim CLeft, CTop, CHeight, CWidth As Double
Dim lotarget As Excel.ListObject
Dim TableTop, i, TargetDataRowsCount As Long
Dim oCheck As OLEObject
Dim Rec_Sht As Worksheet
Dim Opt_Btn_Count As Long

Application.ScreenUpdating = False

Set Rec_Sht = Sheets("Reconcile Meds Here")
Set lotarget = Sheets("Reconcile Meds Here").ListObjects("Table3")
TableTop = lotarget.Range.Row
TableLeft = lotarget.Range.Column
Sort_Index = lotarget.ListColumns("Sort").Index
Opt_Btn_Count = 4

For Each OptBtn In Sheets("Reconcile Meds Here").OptionButtons
        OptBtn.Delete
    Next OptBtn

TargetDataRowsCount = lotarget.DataBodyRange.Rows.Count

For i = 1 To TargetDataRowsCount
If Not IsEmpty(Cells(TableTop + i, "c")) Then
'    GrpBox_Cell = Cells(TableTop + i, "A")
'    Set GrpBox = Rec_Sht.GroupBoxes.Add(Top:=GrpBox_Cell.Top, Left:=GrpBox_Cell.Left, Height:=GrpBox_Cell.Height, Width:=GrpBox_Cell.Width)
'    GrpBox.Name = "GrpBox" & i
For j = 1 To Opt_Btn_Count
        CLeft = Cells(TableTop + i, "A").Left + (Cells(TableTop + i, "A").Width * ((j / Opt_Btn_Count) - 0.25))
        CTop = Cells(TableTop + i, "A").Top ' + Cells(TableTop + i, "A").Height * 0.25
        CHeight = Cells(TableTop + i, "A").Height * 0.5
        CWidth = Cells(TableTop + i, "A").Width / Opt_Btn_Count
                    With Rec_Sht.OptionButtons.Add(Top:=CTop, Left:=CLeft, Height:=CHeight, Width:=CWidth)
                    .Caption = ""
                    .Value = False
                    .Name = "RecBtn" & i & "_" & j
                    .LinkedCell = Cells(TableTop + i, TableLeft + Sort_Index)
                    OptBtnGrp(j) = .Name
                End With
        
         Next j
    End If
Next i
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,223,157
Messages
6,170,418
Members
452,325
Latest member
BlahQz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top