The Next Level

G

Greg

Hi,

I am applying some of my limited skills to create a macro
that will tally checkboxes in a Table column. The
following is working good. I became interested in the line



Sub TallyColumnOfCheckboxes()

Dim cTotal As Integer, i As Integer
cTotal = 0
For i = 1 To ActiveDocument.Tables(1).Rows.Count
On Error Resume Next
cTotal = cTotal - ActiveDocument.Tables(1).Cell _
(i,1).Range.FormFields(1).CheckBox.Value
On Error GoTo 0
Next i
ActiveDocument.FormFields("Total").Result = cTotal

End Sub

I became interested in the line:
(i,1).Range.FormFields(1).CheckBox.Value
and was wondering how would I extend this macro to count
each checkbox in a cell if the cell contain multiple
checkboxes. I deduce that this would require
replacing .FormFields(1) with something like .FormFields
(j) creating a For j = to .... but I can't get my head
around it.

Ideas?

Thanks
 
G

Greg

Wiht spark of brillance or plug luck I stumbled racked
through a solution. Dim J as Integer and

On Error Resume Next
For j = 1 To ActiveDocument.Tables(1).Cell(i,
2).Range.FormFields.Count
cTotal = cTotal - ActiveDocument.Tables(1).Cell(i,
2).Range.FormFields(j).CheckBox.Value
Next j
On Error GoTo 0

Critical comments welcomed.
 

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