VBA & Macro Problems

Trigger Excel Checkbox Macros When Changing All Checkboxes

John WilsonJohn Wilson Nov 11, 2026 869 views

Question details

The user wants to use a command button to check or uncheck multiple ActiveX checkboxes while simultaneously triggering the macros tied to them, such as hiding or unhiding specific columns.

How to Trigger Excel Checkbox Macros When Changing All Checkboxes
Product
Excel
Device & OS
not provided
Scenario
Managing multiple column visibilities using ActiveX checkboxes and controlling them all simultaneously with a 'Select All' or 'Deselect All' command button.
Observed behavior
Changing checkbox values programmatically via a loop must properly trigger the _Click or _Change events, or the macros must be explicitly called to update the sheet.
Before you start

Ensure that the Developer tab is enabled in your Excel ribbon and that macros are allowed to run in the Trust Center settings. Always save your workbook as a Macro-Enabled Workbook (.xlsm) to preserve your VBA code.

Solution 1Recommended

Loop Through OLEObjects to Trigger Events

Iterate through all ActiveX checkboxes on the sheet and change their values programmatically to trigger their native click events.

By changing the Value property of an ActiveX checkbox programmatically via VBA, its associated _Click or _Change event is automatically fired. This ensures that any logic inside those events, such as hiding or unhiding columns, runs correctly without needing duplicate code.

1
Insert ActiveX Checkboxes

Navigate to the Developer tab on the ribbon, click 'Insert', and select 'Check Box' under the ActiveX Controls section. Draw multiple checkboxes on your worksheet.

2
Add Checkbox Event Code

Right-click the sheet tab, select 'View Code', and add the macro logic for each checkbox. For example: Private Sub CheckBox1_Click() Columns("C").Hidden = Not Me.CheckBox1.Value End Sub.

3
Insert a Command Button

Go back to the Developer tab, click 'Insert', and choose a 'Command Button' (ActiveX Control). Place it on the sheet to act as your 'Check All' or 'Uncheck All' button.

4
Write the Loop Logic

Double-click the Command Button to open the VBA editor and write a loop to change the checkbox values. Use code like: For Each obj In ActiveSheet.OLEObjects If TypeName(obj.Object) = "IMdcCheckBox" Then obj.Object.Value = True Next obj.

Loop Through OLEObjects to Trigger Events
Event Triggering: Changing the Value property of ActiveX controls triggers the change event automatically, seamlessly executing your column visibility macros.
Powerful Spreadsheet Tool

Use WPS Spreadsheet for Powerful VBA Macro Support

WPS Office provides comprehensive VBA support, allowing you to create, edit, and run macros seamlessly. You can easily insert ActiveX controls like checkboxes and command buttons to automate your workflow without compatibility issues.

  1. 1. Download and Install: Download and install WPS Office, then launch WPS Spreadsheet.
  2. 2. Access the Developer Tab: Go to the Developer tab and click 'Insert' to add ActiveX Checkboxes and Command Buttons to your sheet.
  3. 3. Add Macro Code: Click 'Visual Basic' or press Alt+F11 to open the built-in VBA editor and paste your automation code.
  4. 4. Save as Macro-Enabled File: Save your file as a Macro-Enabled Workbook (.xlsm) to retain your VBA automation and controls.
Fully compatible with Microsoft Excel (.xlsm) macro filesBuilt-in Developer tab with robust ActiveX controls supportFree and lightweight alternative for complex data managementFamiliar VBA editor environment requiring zero learning curve
microsoft office alternative - wps office

Frequently Asked Questions

Why aren't my Form Control checkboxes triggering macros when changed via VBA?

Form Controls (unlike ActiveX controls) do not have embedded event listeners like _Click. To trigger a macro with a Form Control, you must right-click it, select 'Assign Macro', and link it to a standard module script. Changing their values via VBA won't automatically trigger the assigned macro.

How do I enable the Developer tab to insert checkboxes?

To access form controls and ActiveX tools, go to File > Options > Customize Ribbon. In the right-hand pane, check the box next to 'Developer' and click OK to display the tab.

Can I hide multiple non-adjacent columns with one checkbox?

Yes, in your VBA code, you can define a range of non-adjacent columns (e.g., Range("C:C, E:E, G:G").EntireColumn.Hidden = True) within the checkbox click event to hide them simultaneously.

Why do I get a macro security warning when opening my file?

Spreadsheet software disables macros by default to protect your device from malicious code. You must click 'Enable Content' in the security warning bar at the top of the screen to allow your checkbox macros to execute.