Formula to Determine Number of Checked Check Boxes in Table Column

S

sjane

I have been working with a protected form and have been asked to add a table
to the form which has 5 columns. The first column is a description of an
item and columns B, C, D and E contain check boxes. The last row of the
table is supposed to give the total number of "true" check boxes for each
column. Frankly, I don't have a clue if this is possible. Any and all
assistance would be appreciated.

Sjane
 
H

Helmut Weber

Hi sjane,
shure it is possible, but there a many ways.
First thing I would do is to give all the checkboxes
systematically names (RxCy). Like that for a first empty
table with 4 columns and 9 rows:
Dim r As Integer
Dim c As Integer
Dim s As String
Dim f As Integer
f = 0
With ActiveDocument.Tables(1)
For r = 1 To 9
For c = 1 To 4
f = f + 1
.Cell(r, c).Select
Selection.Collapse
Selection.FormFields.Add _
Range:=Selection.Range, _
Type:=wdFieldFormCheckBox
ActiveDocument.FormFields(f).Select
s = "R" & Trim(Str(r))
s = s & "C" & Trim(Str(c))
ActiveDocument.FormFields(f).Name = s
ActiveDocument.FormFields(f).CheckBox.Value = False
Next
Next
Once You got a system, it's easy.
Dim oFr As formfield
Dim i as integer
For Each oFr In ActiveDocument.FormFields
if left(oFr.name, 2) = "C2" then ' column 2
i = i + ofr.result
end if
Next
Msgbox i ' sum of checked boxes in column 2.
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, NT4.0
 
H

Helmut Weber

Note: This is a hint into the hopefully right direction,
not a ready to use solution. E.G. it does not provide
for documents containing various tables with merged
and split cells and nested tables or whatever.
HW
 
S

sjane

Helmut - sincerest thanks. I think I get the concept. Rather than a
message box with the total, I need a total to appear in the last cell of
each column in order that the number will show up when the document is
printed. Is there a better approach to doing that? Thanks again.

Sjane
 

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

Top