Consulting

Results 1 to 9 of 9

Thread: Need Help About Check Boxes

  1. #1

    Need Help About Check Boxes

    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
    Last edited by usman5594; 07-18-2013 at 01:07 PM.

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Welcome to the forum!

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

  3. #3
    Quote Originally Posted by Kenneth Hobs
    Welcome to the forum!

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

  4. #4
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    You could attach this macro to Check Box 1

    [VBA]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[/VBA]

  5. #5
    Quote Originally Posted by mikerickson
    You could attach this macro to Check Box 1

    [VBA]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[/VBA]
    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
    Last edited by usman5594; 07-18-2013 at 12:17 PM.

  6. #6
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    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.

    [vba]Sub CheckBox1_Click()
    test
    End Sub[/vba]
    or
    [VBA]
    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[/VBA]

  7. #7
    Quote Originally Posted by Kenneth Hobs
    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.

    [vba]Sub CheckBox1_Click()
    test
    End Sub[/vba]
    or
    [VBA]
    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[/VBA]
    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

  8. #8
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    [VBA]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[/VBA]

  9. #9
    Quote Originally Posted by Kenneth Hobs
    [VBA]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[/VBA]
    Kenneth Hobs Grate Job
    Thank You Very Much For My Help
    My problem is solved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •