Option Button Value in Excel

coderedracing used Ask the Experts™
Is it possible to use the value of an Option Box in Excel without linking it to a cell and then refering to that cell?

Something like if(Option Box 4 = "True", "Do Something", "Something Else")

Thank You
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
VBA can read the value of the control itself, but a cell formula cannot.

Attached is a function that can help you bridge that gap.

If you have a checkbox on the worksheet named "Check Box 2", then this formula will determine whether it is checked or not.
=IF(testcheckbox("Check Box 2"),"Is Checked","Is NOT Checked")

Brian Withun

Function TestCheckbox(ControlName As String) As Boolean
    Let TestCheckbox = False
    Dim MyShape As Shape
    For Each MyShape In ActiveSheet.Shapes
        If MyShape.FormControlType = xlCheckBox Then
            If MyShape.Name = ControlName Then
                If MyShape.DrawingObject.Value = 1 Then
                    TestCheckbox = True
                    Exit Function
                End If
            End If
        End If
    Next MyShape
End Function

Open in new window


Thank You!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial