PDA

View Full Version : [SOLVED:] Need Help About Check Boxes



usman5594
07-18-2013, 08:14 AM
i have 5 check boxes in my sheet (check box 1, 2, 3,....)
i need if "check box 1" is checked then "check box 2, 3, and 4" goes to disable and false

Kenneth Hobs
07-18-2013, 08:17 AM
Welcome to the forum!

Are these form or activex controls? You can attach a short example if needed.

usman5594
07-18-2013, 10:07 AM
Welcome to the forum!

Are these form or activex controls? You can attach a short example if needed.
these check boxes from FORM CONTROLS

mikerickson
07-18-2013, 11:40 AM
You could attach this macro to Check Box 1

Sub test()
Dim i As Long
For i = 2 To 4
With Sheet1.Shapes("Check Box " & i).ControlFormat
.Value = xlOff
.Enabled = Not (Sheet1.Shapes("Check Box 1").ControlFormat.Value = xlOn)
End With
Next i
End Sub

usman5594
07-18-2013, 12:00 PM
You could attach this macro to Check Box 1

Sub test()
Dim i As Long
For i = 2 To 4
With Sheet1.Shapes("Check Box " & i).ControlFormat
.Value = xlOff
.Enabled = Not (Sheet1.Shapes("Check Box 1").ControlFormat.Value = xlOn)
End With
Next i
End Sub
this code work profectly,
thank you very much mikerickson this macro work perfectly with 2 to 4
can you make it for multimap check boxes without series i mean for checkbox 2,3,and 5

Kenneth Hobs
07-18-2013, 12:11 PM
Just call test from the macro. You can put test into that sheet's code or a Module. Or, paste the code from test into your macro.

Sub CheckBox1_Click()
test
End Sub
or

Sub CheckBox1_Click()
Dim i As Long
For i = 2 To 4
With Sheet1.Shapes("Check Box " & i).ControlFormat
.Value = xlOff
.Enabled = Not (Sheet1.Shapes("Check Box 1").ControlFormat.Value = xlOn)
End With
Next i
End Sub

usman5594
07-18-2013, 12:22 PM
Just call test from the macro. You can put test into that sheet's code or a Module. Or, paste the code from test into your macro.

Sub CheckBox1_Click()
test
End Sub
or

Sub CheckBox1_Click()
Dim i As Long
For i = 2 To 4
With Sheet1.Shapes("Check Box " & i).ControlFormat
.Value = xlOff
.Enabled = Not (Sheet1.Shapes("Check Box 1").ControlFormat.Value = xlOn)
End With
Next i
End Sub

this macro work perfectly with checkbox 2 to 4
can you make it for multimap check boxes without series i mean for checkbox 2,3,and 5

Kenneth Hobs
07-18-2013, 12:55 PM
Sub CheckBox1_Click()
Dim a() As Variant, v As Variant
a() = Array(2, 3, 5)
For Each v In a()
With Sheet1.Shapes("Check Box " & v).ControlFormat
If Sheet1.Shapes("Check Box 1").ControlFormat.Value = xlOn Then
.Value = xlOff
.Enabled = False
Else: .Enabled = True
End If
End With
Next v
End Sub

usman5594
07-18-2013, 01:06 PM
Sub CheckBox1_Click()
Dim a() As Variant, v As Variant
a() = Array(2, 3, 5)
For Each v In a()
With Sheet1.Shapes("Check Box " & v).ControlFormat
If Sheet1.Shapes("Check Box 1").ControlFormat.Value = xlOn Then
.Value = xlOff
.Enabled = False
Else: .Enabled = True
End If
End With
Next v
End Sub
Kenneth Hobs Grate Job
Thank You Very Much For My Help
My problem is solved