Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to disable a CheckBox based on OptionButton Selection? 1

Status
Not open for further replies.

makeitwork09

Technical User
Sep 28, 2009
170
US
I am using Excel 2007

In a workbook, on the first sheet, I have two option buttons and a checkbox
called OptionButton1, OptionButton2, and CheckBox1, respectively.

In the properties, OptionButton1 and OptionButton2 have a GroupName of
RecType.

The value of OptionButton1 is No

The value of OptionButton2 is Yes

If OptionButton1 is selected I want Checkbox1 to be disabled.

I did the following code, but it is not disabling Checkbox1 when
OptionButton1 is selected.

Code:
Private Sub OptionButton1_Click()

   If OptionButton1 Then
       CheckBox1.Value = False
       CheckBox1.Enabled = False
   End If
End Sub

Private Sub OptionButton2_Click()

   If OptionButton2 Then
       CheckBox1.Value = False
       CheckBox1.Enabled = True
   End If
End Sub
 


I use your code and it works for me.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Wow, you got the checkbox ro disable when you click No?

Hmm...could my properties for the checkbox be different, I wonder?

What do you have set for the value, enabled and groupname for your checkbox?

Thanks
 


tried both true & false for value.

enabled is true

groupname is RecType or Sheet1

Does not matter. Works!

Put a break in both procedures and step thru.

faq707-4594

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
So weird. I do not know why this was not working for me. I deleted the objects and built them again. The objects are now working correctly.

Weird indeed.

Thanks Skip for confirming that it should work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top