Testing whether any one of five checkboxes are selected
Posted by David Megnin on April 30, 2001 11:25 AM
Hello, I'm trying to write a macro that will test whether any one of five checkboxes are selected.
I've tried this:
Sub SelectCheckBox()
If ActiveSheet.CheckBoxes(6).Value = xlOff And ActiveSheet.CheckBoxes(7).Value = xlOff _
And ActiveSheet.CheckBoxes(8).Value = xlOff And ActiveSheet.CheckBoxes(9).Value = xlOff _
And ActiveSheet.CheckBoxes(10).Value = xlOff Then
MsgBox "Nothing was checked"
Else
MsgBox "At least one box was checked"
End If
End Sub
This only indicates whether checkbox(9) or checkbox(10) were selected.
The indexes and checkbox names may be out of sync.
So I entered "activesheet.checkboxes(6).name" in the immediate pane and got "Run-time error '1004': Unable to get the CheckBoxes property of the Worksheet class"
The spreadsheets are usually protected when I receive them and the checkboxes are from the Forms Menu not the Control Box Menu.
Can anyone help me with this?
Thanks very much!