• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 316
  • Last Modified:

Show/Hide ActiveX Option Button

Based on the value in a given cell (B11), I'm hoping to show/hide option button 1 and 2.  Is this possible and/or is my code wrong?  Nothing is happening when you change the value in B11.

Thanks!


If Sheets("Master Variables").Range("B11").Value = True Then
    Sheets("Program Set-Up").OptionButton1.Visible = True
    Sheets("Program Set-Up").OptionButton2.Visible = True
End If

If Sheets("Master Variables").Range("B11").Value = False Then
    Sheets("Program Set-Up").OptionButton1.Visible = False
    Sheets("Program Set-Up").OptionButton2.Visible = False
End If
0
Golfer219
Asked:
Golfer219
  • 3
1 Solution
 
zorvek (Kevin Jones)ConsultantCommented:
Have used the debugger and stepped through the code? Is the above code in the Change event handler?

Kevin
0
 
zorvek (Kevin Jones)ConsultantCommented:
Add this code to the worksheet code module and all will be good:

Private Sub Worksheet_Change(ByVal Target As Range)

    If Not Intersect(Target, [B11]) Is Nothing Then
        Select Case [B11]
            Case True:
                OptionButton1.Visible = True
                OptionButton2.Visible = True
            Case False:
                OptionButton1.Visible = False
                OptionButton2.Visible = False
            Case Else:
                MsgBox "Cell B11 must be TRUE or FALSE."
        End Select
    End If

End Sub

Kevin
0
 
Golfer219Author Commented:
Private Sub CheckBox1_Click()
0
 
zorvek (Kevin Jones)ConsultantCommented:
Is the value in B11 TRUE or FALSE? Is the format of the cell NOT Text?

See attached.

Kevin
Q-27000590.xls
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now