Basics of VBA / Macros Chapter – 53 (Events Part‑2)

⚡ Macro Developer Toolkit

Copy or Export this Code to VBA

Use these verified developer utilities to run this lesson directly inside your Microsoft Excel Visual Basic Editor.

🖇 View Code Example
Basics of VBA / Macros Chapter – 53 (Events Part-2)
⏱ 1 min readUpdated 12 November 2026

BeforeDoubleClick Event

Code added to the Worksheet BeforeDoubleClick Event will be executed by Excel VBA when you double click a cell on a worksheet. Open the Visual Basic Editor. Double click on a sheet (for example Sheet1) in the Project Explorer. Choose Worksheet from the left drop-down list. Choose BeforeDoubleClick from the right drop-down list.

Worksheet BeforeDoubleClick Event in Excel VBA

Advertisement

The ‘_’ symbol is used to continue the statement on a new line (in order to show you the complete code). Add the following code lines to the Worksheet BeforeDoubleClick Event:Β The code line below colors the active cell red.

Target.Font.Color = vbRed

Set the Cancel argument to true if you don’t want the default double click action (cell edit mode) to occur.

Cancel = True

Test the program by double clicking a cell on Sheet1.

Result:

Advertisement

Worksheet BeforeDoubleClick Event Result

✨ Ask AI about this article

Stuck on a step? Ask a question and the AI answers using this article.

Free Β· AI can be wrong