Need help in using check boxes

Gopalakrishnan

Board Regular
Joined
Feb 19, 2013
Messages
110
Hi..

I'm trying to use 5 check boxes and 2 radio controls depending on the check box values. My requirement is to enable those 2 radio controls when the check boxes 3-5 are checked. I've written the code below which partially fulfills my requirement, i.e., it's enabling the radio controls when I check & uncheck the check boxes individually. But when I'm trying to do multiple selection & deselection, it doesn't work as expected.

Code:
Private Sub EstFor_Ch3_Click()
    If EstFor_Ch3.Value = True Then
        IQScr_OP1.Enabled = True
        IQScr_OP2.Enabled = True
        SysTS_OP1.Enabled = True
        SysTS_OP2.Enabled = True
    Else
        IQScr_OP1.Enabled = False
        IQScr_OP2.Enabled = False
        SysTS_OP1.Enabled = False
        SysTS_OP2.Enabled = False
    End If
End Sub

*** repeated the same for Check Box 4 & 5 as well!

Problem I'm facing is here - If I select the check boxes 3, 4, and 5 together then the radio controls get enabled as expected. But when I deselect anyone check box, for instance 3, radio controls get disabled unexpectedly where I'm expecting the code to not disable the control since other two are got selected.

Hope that I've given clear detail about my requirement which is definitely an easier task to forum experts.

Please help me in sorting out it, I've tried to get sample code for check boxes with similar type of usage from forum and out of forum too. But I couldn't find related thread anywhere, so please do the required!

Thanks for your time and any help you can do! :)

P.S: I'm using ActiveX controls

~~ Gopi
 
Last edited:

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Code:
Private Sub CheckBox1_Click()
    Dim chk As CheckBox
    cnt = 0
    For Each chk In ActiveWorkbook.ActiveSheet
        If chk.Value = True Then
            cnt = cnt + 1
        Else
            cnt = cnt
        End If
        
        If cnt >= 1 Then
            OptionButton1.Enabled = True
            OptionButton2.Enabled = True
        Else
            OptionButton1.Enabled = False
            OptionButton2.Enabled = False
        End If
    Next chk
End Sub
something to check that at least one of the checkboxes is selected, if none is selected, it disables the radio buttons/ I wonder how you checked activex controls checkboxes. I couldnt
 
Upvote 0
..... I wonder how you checked activex controls checkboxes. I couldnt

Thanks a lot buddy,,,, your code has given me a better way to resolve my problem,,,,!

And, may be the code I derived from your sample could make you clear that how I'm working with ActiveX controls.

Code:
Private Sub EstFor_Ch3_Click()
Dim chk(3) 'As CheckBox
chk(1) = EstFor_Ch6.Value
chk(2) = EstFor_Ch7.Value
chk(3) = EstFor_Ch8.Value
Dim x As Integer
cnt = 0
    For x = LBound(chk) To UBound(chk)
        If chk(x) = True Then
            cnt = cnt + 1
        Else
            cnt = cnt
        End If
        If cnt >= 1 Then
            IQScr_OP1.Enabled = True
            IQScr_OP2.Enabled = True
            SysTS_OP1.Enabled = True
            SysTS_OP2.Enabled = True
        Else
            IQScr_OP1.Enabled = False
            IQScr_OP2.Enabled = False
            SysTS_OP1.Enabled = False
            SysTS_OP2.Enabled = False
        End If
    Next x
End Sub

Thanks again for your timed help friend! :) Cheers!


~~ Gopi
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top