VBA & Macro Problems

Create and Link Multiple ActiveX Checkboxes in Excel with VBA

Camila MilosovichCamila Milosovich Nov 18, 2026 870 views

Question details

Create and link approximately 150 ActiveX checkboxes without configuring each one individually, and update status and date fields when a checkbox changes.

Product
Microsoft Excel
Device & OS
not provided
Scenario
Each checkbox needs a linked TRUE/FALSE value and corresponding status and date fields on a properties worksheet, with the date also displayed on the checkbox worksheet.
Observed behavior
The desired result is a reusable, data-driven setup that handles checkbox changes without a separate procedure for each control.
Before you start

Use desktop Excel for Windows with ActiveX controls and macros enabled, and save the workbook as an Excel Macro-Enabled Workbook (.xlsm). The example uses sheets named Sheet1 and Properties, rows 2–151, and columns A–B on Sheet1 and B–D on Properties; adjust the names and ranges to fit your layout.

Solution 1Recommended

Create linked checkboxes and handle changes with a VBA class

Use one creation macro and a shared class-based event handler to manage checkbox values, statuses, and dates by row.

This example places checkboxes in Sheet1 column A. Each checkbox links to the corresponding Properties column B cell; the handler writes a status to column C, a date to column D, and the same date to Sheet1 column B. Checking sets today's date; unchecking clears both dates.

The handler collection must remain in memory. The Workbook_Open procedure initializes it whenever the workbook opens with macros enabled, and the creation macro initializes it after adding controls.

1
Add the event class

Press Alt+F11, choose Insert > Class Module, and use the Properties window to name it CheckboxHandler. Paste this code: Public WithEvents Box As MSForms.CheckBox Public RowIndex As Long Private Sub Box_Click() Dim p As Worksheet, s As Worksheet If IsNull(Box.Value) Then Exit Sub Set p = ThisWorkbook.Worksheets("Properties") Set s = ThisWorkbook.Worksheets("Sheet1") If Box.Value = True Then p.Cells(RowIndex, "C").Value = "Complete" p.Cells(RowIndex, "D").Value = Date s.Cells(RowIndex, "B").Value = p.Cells(RowIndex, "D").Value Else p.Cells(RowIndex, "C").Value = "Incomplete" p.Cells(RowIndex, "D").ClearContents s.Cells(RowIndex, "B").ClearContents End If End Sub

2
Add the creation and initialization macros

In the VBA editor, choose Insert > Module and paste the following code. Change the sheet names, row range, or column references if needed: Public CheckboxHandlers As Collection Public Sub BuildCheckboxes() Dim s As Worksheet, o As OLEObject Dim r As Long Set s = ThisWorkbook.Worksheets("Sheet1") For r = 2 To 151 Set o = Nothing On Error Resume Next Set o = s.OLEObjects("cbItem_" & r) On Error GoTo 0 If o Is Nothing Then Set o = s.OLEObjects.Add(ClassType:="Forms.CheckBox.1", _ Left:=s.Cells(r, "A").Left, Top:=s.Cells(r, "A").Top, _ Width:=s.Cells(r, "A").Width, Height:=s.Cells(r, "A").Height) o.Name = "cbItem_" & r o.Object.Caption = "" o.LinkedCell = "'Properties'!B" & r End If Next r InitializeCheckboxes End Sub Public Sub InitializeCheckboxes() Dim o As OLEObject, h As CheckboxHandler Dim suffix As String Set CheckboxHandlers = New Collection For Each o In ThisWorkbook.Worksheets("Sheet1").OLEObjects If Left$(o.Name, 7) = "cbItem_" Then suffix = Mid$(o.Name, 8) If IsNumeric(suffix) And o.progID = "Forms.CheckBox.1" Then Set h = New CheckboxHandler Set h.Box = o.Object h.RowIndex = CLng(suffix) CheckboxHandlers.Add h End If End If Next o End Sub

3
Initialize handlers when the workbook opens

In the VBA editor's Project Explorer, double-click ThisWorkbook and add this procedure: Private Sub Workbook_Open() InitializeCheckboxes End Sub If Workbook_Open already exists, add only the InitializeCheckboxes call to the existing procedure.

4
Run and test the setup

Return to Excel, press Alt+F8, select BuildCheckboxes, and click Run. On the Developer tab, turn off Design Mode if it is enabled. Check and uncheck a control, then verify the corresponding Properties B–D cells and Sheet1 column B. Format the date columns as dates if necessary.

Existing controls and security: The macro skips controls already named cbItem_ followed by the row number; it does not reconfigure them. ActiveX controls may be blocked by Excel security settings. Enable controls and macros only for a workbook you trust.
Free Microsoft Office alternative

Work with Excel spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for common Excel formats, making it easy to move everyday spreadsheet work. Use Microsoft Excel for the ActiveX and VBA solution above; do not assume those controls and macros will run in WPS.

Edit and organize spreadsheet data in a familiar interfaceOpen and save common Microsoft Excel formats, including XLSXReview checkbox-related status and date data in a spreadsheetMove everyday Office work to a lightweight, free suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does each checkbox need a unique name?

The example names controls cbItem_2 through cbItem_151. InitializeCheckboxes reads the row number from each name so the shared handler can update the matching row.

What happens to the date when I uncheck a box?

The example changes the status to Incomplete and clears the dates in Properties column D and Sheet1 column B. Edit the Else block in CheckboxHandler if you want to retain the date instead.

Why do the checkboxes stop updating after I reopen the workbook?

The event handlers must be initialized again. Check that ThisWorkbook contains the Workbook_Open call to InitializeCheckboxes and that macros are enabled for the trusted workbook. You can also run InitializeCheckboxes from Alt+F8.

Can I use this ActiveX solution in Excel for Mac or Excel for the web?

No. This example requires desktop Excel for Windows with ActiveX and VBA support. Excel for Mac and Excel for the web do not support this ActiveX setup.

How do I change the target sheets or number of checkboxes?

In the VBA editor, update the worksheet names in both the standard module and CheckboxHandler. Change the For r = 2 To 151 range in BuildCheckboxes, and adjust the cell references and linked-cell formula to match your layout.