Count Function...in a Word table

GoKats78

Board Regular
Joined
Aug 22, 2008
Messages
166
I have a table in a Word document with Check-boxes (form fields). Is there a way to set up a formula to count the number of boxes checked?

What i need it to do is count the number of checked check-boxes across 4 sections and put the number if a field on the document


 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
I found this bit of code, that should work...

Sub CheckedNo()
Dim Count, n, aVar, num As Integer
Count = 0
For n = 1 To 112 'number of check boxes
If ActiveDocument.FormFields("Check" & n).CheckBox.Value = True Then
Count = Count + 1
End If
Next n
For Each aVar In ActiveDocument.Variables
If aVar.Name = "Count" Then num = aVar.Index
Next aVar
If num = 0 Then
ActiveDocument.Variables.Add Name:="Count", Value:=Count
Else
ActiveDocument.Variables(num).Value = Count
End If
End Sub

But when I try to run it I get this...





"Runtime error 5941" "the requested member of the collection does not exist"
 
Upvote 0

Forum statistics

Threads
1,225,651
Messages
6,186,185
Members
453,339
Latest member
Stu61

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top