OnDoubleClick Property

An OnDoubleClick event handler runs when you double-click anywhere on a sheet. You can use the OnDoubleClick property of a Chart, DialogSheet, or Worksheet object to associate a procedure with double-clicking anywhere on the sheet. You can use the OnDoubleClick property of the Application object to associate the event handler with double-clicking on any sheet in any open workbook.

This property overrides the normal behavior of a double-click in Microsoft Excel. For example, you can double-click a cell to edit its contents in the cell instead of in the formula bar. If you set an OnDoubleClick handler, your event handler can override the in-cell editing. This may confuse users, so be careful when you use the OnDoubleClick property.

The following code runs the DoubleClickEvent procedure whenever you double-click a cell on Sheet1.


Sub TrapDoubleClick()
    Worksheets("Sheet1").OnDoubleClick = "DoubleClickEvent"
End Sub

Sub DoubleClickEvent()
    MsgBox "Something was double-clicked on Sheet1"
End Sub

Note

The OnDoubleClick event handler doesn't run if you simulate double-clicking under program control. For example, the statement Application.DoubleClick simulates double-clicking the active cell, but the OnDoubleClick event handler doesn't run.