counting checkboxes

  • Thread starter Thread starter Manny
  • Start date Start date
M

Manny

Is it possible to count up the "true" values of a series of checkboxes? If
so, what is the formula?
 
The easiest way is to link the checkbox's to cells in your sheets. If the
checkboxes come from the control toolbox then add a reference to the
LinkedCell property (put the sheet in design mode and right click the
checkbox and select Properties). If the check boxes are from the forms
toolbar then right click the check box and select Format control | control.

Once you have linked each checkbox to a cell you can do a simple countif
function to get the number of checks...
 
If you name your CheckBox'es so that they start with the same text
("CheckBox" for this example) and end in numbers of the same length (that
is, use leading zeroes if there are more than 9 CheckBox'es; that is, the
first 9 names should end with 01, 02, 03, etc. instead of just 1, 2, 3,
etc.), then this code will count the number of with check marks in them...

Dim X As Long
Dim Count As Long
Dim C As Control
For Each C In Me.Controls
If C.Name Like "CheckBox##" Then
If C.Value = True Then Count = Count + 1
End If
Next

Rick
 
If the checkboxes were from the ControlToolbox and are on the Worksheet:

Sub chbx()
For i = 1 To 5
If Sheets(1).Shapes(i).Name = "CheckBox" & i Then
If Sheets(1).OLEObjects("CheckBox" & i).Object _
.Value = True Then
x = x + 1
End If
End If
Next
MsgBox x
End Sub

Somebody has already posted the code for other conditions..
 
I just wanted to say thanks to everyone for your help!!! It is surely
appreciated.

Manny
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top