Results 1 to 3 of 3
  1. #1

    Adding CheckBoxes

    I have a table with columns containing checkboxes (one in each cell). I would like to display the total number of checkboxes checked in each column in a cell at the bottom of the column. I'd also like this display to be dynamic so that as users check and uncheck boxes the number is updated. I've figured out a macro that can do each checkbox individually, but I'm looking for something simple that can do an entire column at once.

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    New York, NY
    Thanked 29 Times in 27 Posts

    Re: Adding CheckBoxes

    Assign the following macro to run both On Entry and On Exit for each of your checkboxes - this should do the trick.

    <pre>Sub NumberOfChecksInCol()
    'Gary Frieder January 2001
    Dim lngColNum As Long
    Dim objCurCol As Column
    Dim objCell As Cell
    Dim lngRowCt As Long
    Dim objFrmFld As FormField
    Dim lngChkCt As Long

    If Selection.Information(wdWithInTable) Then
    lngColNum = Selection.Information(wdEndOfRangeColumnNumber)
    'there is no Column.Range object!
    Set objCurCol = Selection.Tables(1).Columns(lngColNum)
    'there is no Column.Rows object!
    lngRowCt = objCurCol.Cells.Count
    'there is no Cells.Range object!
    For Each objCell In objCurCol.Cells
    For Each objFrmFld In objCell.Range.FormFields
    If objFrmFld.Type = wdFieldFormCheckBox Then
    If objFrmFld.CheckBox.Value = True Then
    lngChkCt = (lngChkCt + 1)
    End If
    End If
    Next objFrmFld
    Next objCell
    'convert lngChkCt to string and get it into last cell in col
    objCurCol.Cells(lngRowCt).Range.Text = Str$(lngChkCt)
    End If
    End Sub

  3. #3

    Re: Adding CheckBoxes

    Vexed By Checkbox Text

    Well done, Gary.

    This is one of those issues that I

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts