Office Settings & Configuration

How to Count Checked Checkboxes in Separate Microsoft Word Tables Using VBA

Rana GarciaRana Garcia Oct 22, 2026 871 views

Question details

The user needs a way to count the number of checked checkboxes located within distinct tables in a Microsoft Word document using a VBA macro.

How to Count Checked Checkboxes in Separate Microsoft Word Tables
Product
Microsoft Word
Device & OS
not provided
Scenario
Automating a Word document containing multiple tables with checkboxes, requiring a separate and accurate tally of checked items for each table.
Observed behavior
Different types of checkboxes (Content Controls, Legacy Form Fields, ActiveX) require specific VBA methods, properties, and object collections to accurately tally values without cross-table interference.
Before you start

Ensure the Developer tab is enabled in your Word ribbon to access the VBA editor, and verify whether your document uses Content Controls, Legacy Form Fields, or ActiveX checkboxes, as this determines the VBA logic.

Solution 1Recommended

Use VBA to Count Content Control Checkboxes

This is the recommended approach for modern Word documents using Content Control checkboxes. It restricts the macro loop to specific tables to prevent overlapping counts.

Content Control checkboxes are standard in newer versions of Word. To count them per table, you must restrict your loop to the specific Table object's range rather than the entire document.

1
Open the VBA Editor

Press ALT + F11 on your keyboard to open the Microsoft Visual Basic for Applications (VBA) editor.

2
Insert a New Module

Click on Insert > Module in the top menu to create a blank workspace for your macro code.

3
Write the Loop Logic

Create a loop targeting a specific table, for example: For Each ctrl In ActiveDocument.Tables(1).Range.ContentControls. Check if ctrl.Type = wdContentControlCheckBox and if ctrl.Checked = True, then increment a counter variable.

4
Output the Tally

Write the final counter value to a specific cell within that table, such as ActiveDocument.Tables(1).Cell(RowIndex, ColumnIndex).Range.Text = counter.

5
Run the Macro

Press F5 or run the macro from the Developer tab to calculate and update the check counts.

Use VBA to Count Content Control Checkboxes
Automating the Count: To update counts immediately upon clicking a checkbox, attach this counting logic to the Document_ContentControlOnExit event.
Seamless Macro Support

Automate Documents and Macros Easily in WPS Writer

WPS Office fully supports VBA macros, allowing you to run scripts that count checked checkboxes in tables just like Microsoft Word. It provides a highly compatible environment for your document automation needs.

  1. 1. Download and Install WPS Office: Get the latest version of WPS Office and open your macro-enabled document (.docm) in WPS Writer.
  2. 2. Enable the Developer Tab: Navigate to the settings in WPS Writer to ensure the Developer tab is visible on your ribbon for macro access.
  3. 3. Open the Macro Editor: Click on the Developer tab, select 'Macros' or 'Visual Basic', and paste your checkbox-counting VBA code.
  4. 4. Execute the Code: Run the macro directly within WPS Writer to instantly tally the checked boxes across your tables.
Full support for VBA macros and advanced document automationHigh compatibility with Microsoft Word documents (.docx) and macro-enabled files (.docm)Easily insert and manage form controls, checkboxes, and legacy fieldsFree, lightweight, and fast-loading alternative to MS Office
microsoft office alternative - wps office

Frequently Asked Questions

How do I know which type of checkbox I am using in Word?

Click on the checkbox. If a bounding box with a 'Content Control' tab appears, it is a Content Control. If you must protect the document for forms to check it, it is a Legacy Form Field. If it behaves like an embedded object, it is an ActiveX control.

Why is my VBA macro counting checkboxes from the whole document instead of just one table?

Your code is likely looping through ActiveDocument.ContentControls instead of restricting the range. Ensure you target a specific table by using ActiveDocument.Tables(Index).Range.ContentControls.

Can I make the checkbox count update automatically when a user clicks it?

Yes, but it requires attaching your macro to a document event (like ContentControlOnExit for Content Controls) or the Click event for ActiveX controls, so the count recalculates immediately upon interaction.

Do I need to save my document differently after adding this macro?

Yes, you must save your Microsoft Word document as a Word Macro-Enabled Document (.docm). If you save it as a standard .docx file, all VBA code will be stripped and permanently lost.