Select All Checkboxes on Excel worksheet
Select All Checkboxes on Excel worksheet
(OP)
Hello! I have an Excel worksheet with 6 checkboxes on them. The first checkbox is supposed to check all checkboxes when it is clicked. I have the code below:
Private Sub Checkbox0_Click()
If CheckBox0.Value = True Then
Dim i As Integer
For i = 1 To 5
CheckBox(i).Value = True
Next i
End If
End Sub
However, on running it in VBA, it gives me a compile error saying "Sub or Function is not defined". What is the right syntax to loop each check box and make them all true?
Private Sub Checkbox0_Click()
If CheckBox0.Value = True Then
Dim i As Integer
For i = 1 To 5
CheckBox(i).Value = True
Next i
End If
End Sub
However, on running it in VBA, it gives me a compile error saying "Sub or Function is not defined". What is the right syntax to loop each check box and make them all true?





RE: Select All Checkboxes on Excel worksheet
..take a look at this thread
http://www
RE: Select All Checkboxes on Excel worksheet
If Checbox0.Value = True Then
Checkbox1.Value = True
Checkbox2.Value = True
Checkbox3.Value = True
Checkbox4.Value = True
Checkbox5.Value = True
End If
Problem solved.
RE: Select All Checkboxes on Excel worksheet
CODE
For Each ct In Me.OLEObjects
With ct.Object
If .GroupName = "A" Then .Value = CheckBox0.Value
End With
Next ct
End Sub