Check boxes not working
Wow, I guess that must have been my mistake. I didn't know there were two
types of check boxes. Tom, the code you sent me worked perfectly. This will
enable me to set auto-updating tally sheets for my friend's business.
Am I able to make arrays of all buttons and shapes (i.e. radio buttons) and
perform this same type of check on them, too? How do I know what name to
call them (i.e. CheckBoxes, OptionButtons, others are...)?
Thanks to all,
Pflugs
"Tom Ogilvy" wrote:
Looks like you have checkboxes form the forms toolbar. I will assume the
names in your array are correct. It you get an error, that is the first
place to look.
Sub CheckBox1_Click()
Dim mycheckboxes As Variant
Dim box
mycheckboxes = Array("checkbox1", "check box 5", _
"check box 6", "check box 7")
Dim cost As Long
cost = 0
For Each box In mycheckboxes
If Activesheet.CheckBoxes(box).Value = xlOn Then
cost = cost + 1
End If
Next
Range("j7").Value = cost
End Sub
--
Regards,
Tom Ogilvy
"Pflugs" wrote in message
...
I am not able to access check boxes through macros. I searched the help
files and this forum, and I know that I am supposed to use something like
"CheckBox1", but it keeps telling me that "Object Required."
Here's my code:
Sub CheckBox1_Click()
Dim mycheckboxes As Variant
mycheckboxes = (Array("checkbox1", "check box 5", "check box 6", "check
box
7"))
Dim cost As Integer
cost = 0
For Each box In mycheckboxes
If box.Value = Checked Then
cost = cost + 1
End If
Next
Range("j7").Value = cost
End Sub
Thanks for the advice.
|