Newbie : question on VBA and checkboxes
Hi Daniel,
The following works if you only have check boxes (or you could test the name
of the object) but I am interested if anyone can tell me how to determine if
the object is a checkbox because it picks up all objects.
Sub macro2()
Dim oleChk As OLEObject
For Each oleChk In ActiveSheet.OLEObjects
If oleChk.Object.Value = True Then
MsgBox oleChk.Name & " = " & oleChk.Object.Value
Else
MsgBox oleChk.Name & " = " & oleChk.Object.Value
End If
Next oleChk
End Sub
Regards,
Ossiemac
"Daniel" wrote:
Hi everybody.
I have this worksheet which contains one checkbox on each line of a specific
column, let's say Checkbox1 to checkbox20.
I can determine whether the checkboxes are checked or not using instructions
such as :
If ActiveSheet.CheckBoxes1.Value = True Then [Process]
However I would like to use a For / Next routine to test all the checkboxes.
I entered the following code, but it doesn't work and generates an error
message :
For i = 1 To n 'n = number of lines
If ActiveSheet.CheckBoxes(i).Value = True Then
[Process]
End If
Next i
The error message indicates :
Error 1004.
"Impossible to read the Checkbox property of the worksheet class " (sorry,
it's a lousy translation of the French version of Excel).
What did I do wrong ? What should I do ?
I am using Excel 2002
again, many tks in advance for your time and kind help.
Brgds,
Daniel
|