VBA & Macro Problems

Toggle Check Marks on Double-Click in Two Excel Columns

Phi Hung VoPhi Hung Vo Nov 27, 2026 868 views

Question details

Extend an existing Excel double-click macro so it toggles check marks in two separate column ranges.

Toggle Check Marks on Double-Click in Two Excel Columns
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet uses a Worksheet_BeforeDoubleClick event to insert or remove check marks in B3:B50, and the same behavior is needed in G3:G50.
Observed behavior
The existing macro handles B3:B50 but does not handle G3:G50.
Before you start

Open the workbook in a desktop version of Excel that supports VBA, and locate the existing Worksheet_BeforeDoubleClick procedure in the relevant worksheet's code module. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) and enable macros if prompted.

Solution 1Recommended

Expand the double-click event range to include both columns

Use this change to keep the existing check-mark toggle logic while applying it to B3:B50 and G3:G50.

1
Open the worksheet code

Right-click the relevant worksheet tab in Excel and select View Code. Find its existing Worksheet_BeforeDoubleClick procedure.

2
Update the range condition

Replace the existing Intersect condition with: If Not Intersect(Target, Me.Range("B3:B50,G3:G50")) Is Nothing Then

3
Keep the toggle logic and cancel editing

Inside that If block, retain the existing code that inserts or removes the check mark, and make sure it includes Cancel = True. Leave the closing End If and End Sub in place.

4
Save and test

Save the .xlsm workbook, return to the worksheet, and double-click a cell in each range twice. The check mark should appear and then disappear without entering normal cell-editing mode.

Expand the double-click event range to include both columns
Existing cell contents: The effect on cells containing other values or formulas depends on the existing toggle code. Check that code before using the macro on populated cells.
Free Microsoft Office alternative

Work with Excel spreadsheets in WPS Office

WPS Office is a free, lightweight Office alternative with a familiar interface for opening and editing spreadsheets. Its Excel format compatibility can make moving everyday spreadsheet work easier, although it does not fix Excel's VBA event code and macro support may differ.

Open and edit Excel XLSX and XLS spreadsheet filesWork with spreadsheet data in a familiar interfaceUse a free, lightweight Office alternativeContinue everyday spreadsheet work when moving from Microsoft Office
QA img-9

Frequently Asked Questions

Where should I put the Worksheet_BeforeDoubleClick code?

Right-click the relevant worksheet tab and select View Code. The event procedure belongs in that worksheet's code module, not in a standard module.

Why does the cell enter edit mode when I double-click it?

Make sure Cancel = True is inside the If block for the target ranges. This prevents Excel's normal double-click editing behavior for those cells.

Will the macro run outside B3:B50 and G3:G50?

The toggle code inside the Intersect condition runs only when the double-clicked cell is in B3:B50 or G3:G50. Other code in the event procedure may still run.

Why did my VBA code disappear after saving?

An .xlsx file cannot retain VBA macros. Use File > Save As and select Excel Macro-Enabled Workbook (.xlsm) to preserve the code.