Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting populated checkboxes and putting the sum in a table cell

Status
Not open for further replies.

FergieRKF

Technical User
Oct 19, 2009
2
0
0
US
thread68-853587
Hi Folks,

By way of preface let me apologize that I am not a programmer/developer. I may not use the proper vernacular when describing my needs.

I have a Word document that contains content controls; plain text, datepicker, and checkboxes.
For this puzzle, I am interested in manipulating the columns that contain the datepicker and checkbox controls.

Section two of the document has the datepicker and checkbox columns and sections 3, 4, and 5 have checkboxes.

In the referenced thread, I saw methods for capturing the number of populated checkboxes and displaying them to the user in a MsgBox.
I would like to know if there is a way to:

1. Capture the number of cells that contain a date,
2. Capture the number of checkboxes populated, and
3. Move those values to their respective "Totals:" cell at the bottom of the table.

Respectfully,

Fergie



 
 http://files.engineering.com/getfile.aspx?folder=d915f520-6ab1-4e84-a3b6-91f23a8bc0ca&file=Screening_Checklist4TekTips-26APR17-RKF.docx
Dim ctrl As Control
Dim cntr as Long
cntr = 0
For Each ctrl In Form.Controls 'this goes thru each control in the form
With ctrl
Select Case .ControlType
Case CheckBox 'if the control is a checkbox
If .value = -1 Then 'if the checkbox is checked then
cntr = cntr + 1 'count it
End If
End Select
End With
Next ctrl
 
FergieRKF: You say you want to output the # of cells with dates to it's ' "Totals:" cell at the bottom of the table', but there is no such cell evident for the dates. While there is a 'Total Completed:' and a 'Total NA:' entry in the last two rows of the Part A & Part B tables, whatever their output might be (which isn't apparent), appears to be required in the checkbox column. Please clarify your expectations as to what the 'Total Completed:' and a 'Total NA:' rows should contain.

LaurieHamlin: Your code, which assumes a userform, isn't at all applicable. As FergieRKF clearly said, and as the linked document demonstrates, the required code is for content controls in the document itself.



Cheers
Paul Edstein
[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top