Re: Formula to Determine Number of Checked Check Boxes in Table Column by sjane
sjane
Tue Sep 16 07:34:05 CDT 2003
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
"Helmut Weber" <h.weber@nospam.de> wrote in message
news:0ee901c37be0$f75a0af0$a001280a@phx.gbl...
> 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
>
>
>
>