Home > database >  Refer to option button in a frame activex in Worksheet
Refer to option button in a frame activex in Worksheet

Time:04-21

How can I refer to an option button whitin a activeX frame?

I need, e.g., to know if it is active (True) ou not (False).

In the image below, it outlines the steps I went through to get the OB's I need to reference.

enter image description here

Thanks in advance!

CodePudding user response:

To check which option button was selected, you'll need to loop through each control within the frame . . .

Dim ctrl As MSForms.Control
For Each ctrl In Worksheets("Sheet1").Frame1.Controls
    If TypeName(ctrl) = "OptionButton" Then
        If ctrl.Value = True Then
            Exit For
        End If
    End If
Next ctrl

If ctrl Is Nothing Then
    MsgBox "Nothing selected!", vbExclamation
Else
    MsgBox ctrl.Name & " has been selected!", vbExclamation
End If
  • Related