VBA & Macro Problems

Toggle a Check Mark with a Double-Click in Excel VBA

Nimra MalikNimra Malik Nov 25, 2026 869 views

Question details

Toggle a check mark on and off by double-clicking cells in a worksheet column.

Toggle a Check Mark with a Double-Click in Excel VBA
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet uses a designated range as a list of cells to check or clear.
Observed behavior
Double-clicking an empty cell should add a check mark; double-clicking it again should clear it.
Before you start

Open the workbook in desktop Excel and identify the worksheet and cell range you want to use. The example uses A1:A10 and clears any existing content in a nonempty cell when it is double-clicked.

Solution 1Recommended

Use the Worksheet BeforeDoubleClick event

Add worksheet event code to toggle marks only when a cell in the specified range is double-clicked.

1
Open the worksheet code

In Excel, select Developer > Visual Basic. In the VBA editor's Project Explorer, double-click the worksheet where you want the check marks.

2
Add the event code

Paste this code into the worksheet's code window: Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Target.CountLarge <> 1 Then Exit Sub If Intersect(Target, Me.Range("A1:A10")) Is Nothing Then Exit Sub Cancel = True If IsEmpty(Target.Value2) Then Target.Value = ChrW(&H2713) Else Target.ClearContents End If End Sub

3
Set your range

In the code window, replace A1:A10 with the cells you want to use. Keep the event code in that worksheet's module, not a standard module.

4
Save and test

Use File > Save As and choose Excel Macro-Enabled Workbook (.xlsm). Enable macros only if you trust the file, then double-click a cell in the range twice to add and remove the mark.

Use the Worksheet BeforeDoubleClick event
Existing cell content: Double-clicking a nonempty cell in the range clears its contents, including formulas. Cancel = True prevents Excel from entering cell edit mode for the handled cells.
Free Microsoft Office alternative

Work with checklists in WPS Spreadsheets

WPS Office is a free, lightweight Office alternative with a familiar interface and Excel format compatibility for easier migration. You can edit checklist cells in WPS Spreadsheets, but this Excel VBA event may not work in every WPS edition.

Edit spreadsheet checklists in a familiar interfaceCompatible with common Microsoft Excel formats, including XLSX and XLSFree and lightweight for everyday spreadsheet workOpen existing workbooks to make migration easier
microsoft office alternative - wps office

Frequently Asked Questions

Why use BeforeDoubleClick instead of SelectionChange?

Worksheet_BeforeDoubleClick runs when you double-click a cell. SelectionChange runs when you select a cell, which could change a mark when you only intended to move around the worksheet.

How do I change which cells can be toggled?

Open the worksheet code through Developer > Visual Basic and replace A1:A10 in Me.Range("A1:A10") with your desired range.

Why does double-clicking no longer open a cell for editing?

The code sets Cancel = True for cells in the specified range to prevent Excel from entering edit mode. Cells outside that range retain their normal double-click behavior.

Why must I save the workbook as an XLSM file?

The XLSM format preserves VBA code. Use File > Save As and select Excel Macro-Enabled Workbook; an XLSX file cannot retain the macro.