Silverjman
Board Regular
- Joined
- Mar 19, 2014
- Messages
- 110
i.e. not all the check boxes on the active sheet like the following:
I would think that the <> is the problem, I've replaced "Check Box 1" with "AllCountrys" and was hoping a simple "Country*" (* = wildcard?) would pick up "Country1", "Country2", etc. or an = LEFT(), or group and name them and then .GroupName = ....("Country") but frankly I'm just too ignorant of VBA to get anywhere.
Also hopefully clicking the Select All check box would also uncheck all boxes if checked...:\ : |
or
please thanks please
I would think that the <> is the problem, I've replaced "Check Box 1" with "AllCountrys" and was hoping a simple "Country*" (* = wildcard?) would pick up "Country1", "Country2", etc. or an = LEFT(), or group and name them and then .GroupName = ....("Country") but frankly I'm just too ignorant of VBA to get anywhere.
Also hopefully clicking the Select All check box would also uncheck all boxes if checked...:\ : |
Code:
Sub SelectAll_Click()
Dim CB As CheckBox
For Each CB In ActiveSheet.CheckBoxes
If CB.Name <> ActiveSheet.CheckBoxes("Check Box 1").Name Then
CB.Value = ActiveSheet.CheckBoxes("Check Box 1").Value
End If
Next CB
End Sub
Sub Mixed_State()
Dim CB As CheckBox
For Each CB In ActiveSheet.CheckBoxes
If CB.Name <> ActiveSheet.CheckBoxes("Check Box 1").Name And CB.Value <> ActiveSheet.CheckBoxes("Check Box 1").Value And ActiveSheet.CheckBoxes("Check Box 1").Value <> 2 Then
ActiveSheet.CheckBoxes("Check Box 1").Value = 2
Exit For
Else
ActiveSheet.CheckBoxes("Check Box 1").Value = CB.Value
End If
Next CB
End Sub
or
Code:
Sub CheckAllBoxes()
SetAllFormsCheckboxes True
End Sub
Sub UnCheckAllBoxes()
SetAllFormsCheckboxes False
End Sub
Sub toggleAllBoxes()
SetAllFormsCheckboxes False, True
End Sub
Sub SetAllFormsCheckboxes(ByVal newValue As Boolean, Optional Toggle As Boolean)
Dim oneShape As Object
For Each oneShape In ActiveSheet.Shapes
With oneShape
If .Type = msoFormControl Then
If .FormControlType = xlCheckBox Then
If Toggle Then newValue = Not (.ControlFormat.Value = xlOn)
.ControlFormat.Value = IIf(newValue, xlOn, xlOff)
End If
End If
End With
Next oneShape
End Sub
please thanks please