Reply
 
Thread Tools Display Modes
  #1   Report Post  
Don
 
Posts: n/a
Default Calculating check boxes

I have a several columns of check boxes in a table and would like to total
the number of True boxes for each column. Can this be done?
--
Don
  #2   Report Post  
Greg Maxey
 
Posts: n/a
Default

Don,

Yes it can by using macros. I am a novice with VBA and rusty to boot, but
here is an example of code to tally the results of check boxes in columns 2,
3, 4, and 5 (I used labels b, c, d, e) of a table that might get you
started. You will need to insert text fields in the last row of the columns
bookmarked as indicated in the code to hold the results.

If you have further problems you might want to post in the VBA beginner or
general group where the heavies hang out.

Sub TallyResults()

Dim bTotal As Integer, cTotal As Integer, dTotal As Integer, eTotal As
Integer

bTotal = 0
cTotal = 0
dTotal = 0
eTotal = 0

For i = 1 To ActiveDocument.Tables(1).Rows.Count
On Error Resume Next
bTotal = bTotal - ActiveDocument.Tables(1).Cell(i,
2).Range.FormFields(1).CheckBox.Value
cTotal = cTotal - ActiveDocument.Tables(1).Cell(i,
3).Range.FormFields(1).CheckBox.Value
dTotal = dTotal - ActiveDocument.Tables(1).Cell(i,
4).Range.FormFields(1).CheckBox.Value
eTotal = eTotal - ActiveDocument.Tables(1).Cell(i,
5).Range.FormFields(1).CheckBox.Value

Next i
ActiveDocument.FormFields("bTotal").Result = bTotal
ActiveDocument.FormFields("cTotal").Result = cTotal
ActiveDocument.FormFields("dTotal").Result = dTotal
ActiveDocument.FormFields("eTotal").Result = eTotal

End Sub


--
Greg Maxey/Word MVP
A Peer in Peer to Peer Support

Don wrote:
I have a several columns of check boxes in a table and would like to
total the number of "True" boxes for each column. Can this be done?



  #3   Report Post  
Don
 
Posts: n/a
Default

Thanks. I have not had time to try this yet, but it looks like it makes sense.

"Don" wrote:

I have a several columns of check boxes in a table and would like to total
the number of True boxes for each column. Can this be done?
--
Don

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Check Boxes not working NCI Neil Microsoft Word Help 3 April 1st 07 04:22 AM
how do i make check mark boxes in mircosoft word//?? need some help .. Microsoft Word Help 1 January 12th 05 03:02 AM
Check boxes Kelly Microsoft Word Help 3 December 29th 04 04:43 PM
how do i insert boxes in text (to check off later when printed)? creating check boxes Microsoft Word Help 1 December 19th 04 12:46 PM
Check boxes in a Word form nchambers Microsoft Word Help 3 December 15th 04 09:02 AM


All times are GMT +1. The time now is 09:00 AM.

Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
Copyright 2004-2023 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"