BeforeDoubleClick Event

Microsoft Excel Visual Basic

Occurs when a worksheet is double-clicked, before the default double-click action.

Private Sub expression_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

expression    A variable which references an object of type Worksheet declared with events in a class module.

Target Required. The cell nearest to the mouse pointer when the double-click occurs.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the default double-click action isn't performed when the procedure is finished.

ShowActivate method as it applies to the Chart object.

Occurs when an embedded chart is double-clicked, before the default double-click action.

Private Sub expression_BeforeDoubleClick(ByVal ElementID As Long, ByVal Arg1 As Long, ByVal Arg2 As Long, Cancel As Boolean)

expression    A variable which references an object of type Chart declared with events in a class module.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the default double-click action isn't performed when the procedure is finished.

ElementID Required. The double-clicked object The meaning of Arg1    and Arg2    depends on the ElementID    value, as shown in the following table.

ElementID Arg1 Arg2
xlAxis AxisIndex AxisType
xlAxisTitle AxisIndex AxisType
xlDisplayUnitLabel AxisIndex AxisType
xlMajorGridlines AxisIndex AxisType
xlMinorGridlines AxisIndex AxisType
xlPivotChartDropZone DropZoneType None
xlPivotChartFieldButton DropZoneType PivotFieldIndex
xlDownBars GroupIndex None
xlDropLines GroupIndex None
xlHiLoLines GroupIndex None
xlRadarAxisLabels GroupIndex None
xlSeriesLines GroupIndex None
xlUpBars GroupIndex None
xlChartArea None None
xlChartTitle None None
xlCorners None None
xlDataTable None None
xlFloor None None
xlLegend None None
xlNothing None None
xlPlotArea None None
xlWalls None None
xlDataLabel SeriesIndex PointIndex
xlErrorBars SeriesIndex None
xlLegendEntry SeriesIndex None
xlLegendKey SeriesIndex None
xlSeries SeriesIndex PointIndex
xlTrendline SeriesIndex TrendLineIndex
xlXErrorBars SeriesIndex None
xlYErrorBars SeriesIndex None
xlShape ShapeIndex None

The following table describes the meaning of the arguments.

Argument Description
AxisIndex Specifies whether the axis is primary or secondary. Can be one of the following XlAxisGroup constants: xlPrimary or xlSecondary.
AxisType Specifies the axis type. Can be one of the following XlAxisType constants: xlCategory, xlSeriesAxis, or xlValue.
DropZoneType Specifies the drop zone type: column, data, page, or row field. Can be one of the following XlPivotFieldOrientation constants: xlColumnField, xlDataField, xlPageField, or xlRowField. The column and row field constants specify the series and category fields, respectively.
GroupIndex Specifies the offset within the ChartGroups collection for a specific chart group.
PivotFieldIndex Specifies the offset within the PivotFields collection for a specific column (series), data, page, or row (category) field.
PointIndex Specifies the offset within the Points collection for a specific point within a series. The value – 1 indicates that all data points are selected.
SeriesIndex Specifies the offset within the Series collection for a specific series.
ShapeIndex Specifies the offset within the Shapes collection for a specific shape.
TrendlineIndex Specifies the offset within the Trendlines collection for a specific trendline within a series.

Remarks

The DoubleClick method doesn't cause this event to occur.

This event doesn't occur when the user double-clicks the border of a cell.

Example

ShowAs it applies to the Chart object.

This example overrides the default double-click behavior for the chart floor.

Private Sub Chart_BeforeDoubleClick(ByVal ElementID As Long, _
    ByVal Arg1 As Long, ByVal Arg2 As Long, Cancel As Boolean)

    If ElementID = xlFloor Then
        Cancel = True
        MsgBox "Chart formatting for this item is restricted."
    End If

End Sub