Hi all,
This is probably a dumb question, but I can't for the life of me figure out how to assign a name to an ActiveX Option Button when creating it, other than "OptionButton1", "OptionButton2", etc
Just to clarify, I don't want to have to change the name in the properties box for each option button.
Here's the code:
Any ideas?
Thanks!
This is probably a dumb question, but I can't for the life of me figure out how to assign a name to an ActiveX Option Button when creating it, other than "OptionButton1", "OptionButton2", etc
Just to clarify, I don't want to have to change the name in the properties box for each option button.
Here's the code:
Code:
Sub Add_XCheckboxes()
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
Opt_Btn_Count = 4
For Each oCheck In Sheets("Reconcile Meds Here").OLEObjects
oCheck.Delete
Next oCheck
TargetDataRowsCount = lotarget.DataBodyRange.Rows.Count
For i = 1 To TargetDataRowsCount
If Not IsEmpty(Cells(TableTop + i, "c")) Then
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
CHeight = Cells(TableTop + i, "A").Height * 0.5
CWidth = Cells(TableTop + i, "A").Width * 0.5
With Rec_Sht.OLEObjects.Add(ClassType:="Forms.Optionbutton.1", _
Top:=CTop, Left:=CLeft, Height:=CHeight, Width:=CHeigh)
.Object.Caption = ""
.LinkedCell = "k" & TableTop + i
.Object.Value = False
.Object.GroupName = "Med rec" & i
End With
Cells(TableTop + i, "B") = i
Next j
End If
Next i
Application.ScreenUpdating = True
End Sub
Any ideas?
Thanks!