G
Greg Maxey
Hi,
Yesterday I created and posted the following crude macro to someone looking
for a way to add up the choices made in a list. The idea being a table with
a column of questions and three columns headed Yes, No, and Maybe. For each
question there is a checkbox in the headed columns. The user needs to tally
the number of checked boxes in each column and display the result in the
final row:
Sub Countboxes()
Dim Yes As Long
Dim No As Long
Dim Maybe As Long
With ActiveDocument
If .FormFields("Yes1").Result = True Then
Yes = Yes + 1
End If
If .FormFields("Yes2").Result = True Then
Yes = Yes + 1
End If
'Repeat adding the above If string for each Yes checkbox.
If .FormFields("No1").Result = True Then
No = No + 1
End If
If .FormFields("No2").Result = True Then
No = No + 1
End If
If .FormFields("Maybe1").Result = True Then
Maybe = Maybe + 1
End If
If .FormFields("Maybe2").Result = True Then
Maybe = Maybe + 1
End If
ActiveDocument.FormFields("Text1").Result = Yes
ActiveDocument.FormFields("Text2").Result = No
ActiveDocument.FormFields("Text3").Result = Maybe
End With
End Sub
For this macro to work, each formfield check box must be named and there
must be three lines of code for each checkbox. OK as is for a small list,
but if it was of any size it is soon too laborious to pursue.
Question. Is it possible to write this something like:
dim FF as formfield
For each FF.type (checkbox) in column "Yes" If result = True Then
Yes = Yes + 1
next FF
For each FF.type(checkbox) in column "NO" If result = True Then
No = No +1
etc.?
Thanks.
--
\\\\///////////
( @ @ )
----oo00---(_)---00oo----
Greg Maxey
A peer in "peer to peer" support
Rockledge, FL
Yesterday I created and posted the following crude macro to someone looking
for a way to add up the choices made in a list. The idea being a table with
a column of questions and three columns headed Yes, No, and Maybe. For each
question there is a checkbox in the headed columns. The user needs to tally
the number of checked boxes in each column and display the result in the
final row:
Sub Countboxes()
Dim Yes As Long
Dim No As Long
Dim Maybe As Long
With ActiveDocument
If .FormFields("Yes1").Result = True Then
Yes = Yes + 1
End If
If .FormFields("Yes2").Result = True Then
Yes = Yes + 1
End If
'Repeat adding the above If string for each Yes checkbox.
If .FormFields("No1").Result = True Then
No = No + 1
End If
If .FormFields("No2").Result = True Then
No = No + 1
End If
If .FormFields("Maybe1").Result = True Then
Maybe = Maybe + 1
End If
If .FormFields("Maybe2").Result = True Then
Maybe = Maybe + 1
End If
ActiveDocument.FormFields("Text1").Result = Yes
ActiveDocument.FormFields("Text2").Result = No
ActiveDocument.FormFields("Text3").Result = Maybe
End With
End Sub
For this macro to work, each formfield check box must be named and there
must be three lines of code for each checkbox. OK as is for a small list,
but if it was of any size it is soon too laborious to pursue.
Question. Is it possible to write this something like:
dim FF as formfield
For each FF.type (checkbox) in column "Yes" If result = True Then
Yes = Yes + 1
next FF
For each FF.type(checkbox) in column "NO" If result = True Then
No = No +1
etc.?
Thanks.
--
\\\\///////////
( @ @ )
----oo00---(_)---00oo----
Greg Maxey
A peer in "peer to peer" support
Rockledge, FL