The Chart_Select procedure listed next is executed whenever an item on the chart is selected: : Chart Event « Excel « VBA / Excel / Access / Word






The Chart_Select procedure listed next is executed whenever an item on the chart is selected:

 
Private Sub Chart_Select(ByVal ElementID As Long, _
  ByVal Arg1 As Long, ByVal Arg2 As Long)
    Select Case ElementID
        Case xlChartArea: Id = "ChartArea"
        Case xlChartTitle: Id = "ChartTitle"
        Case xlPlotArea: Id = "PlotArea"
        Case xlLegend: Id = "Legend"
        Case xlFloor: Id = "Floor"
        Case xlWalls: Id = "Walls"
        Case xlCorners: Id = "Corners"
        Case xlDataTable: Id = "DataTable"
        Case xlSeries: Id = "Series"
        Case xlDataLabel: Id = "DataLabel"
        Case xlTrendline: Id = "Trendline"
        Case xlErrorBars: Id = "ErrorBars"
        Case xlXErrorBars: Id = "XErrorBars"
        Case xlYErrorBars: Id = "YErrorBars"
        Case xlLegendEntry: Id = "LegendEntry"
        Case xlLegendKey: Id = "LegendKey"
        Case xlAxis: Id = "Axis"
        Case xlMajorGridlines: Id = "MajorGridlines"
        Case xlMinorGridlines: Id = "MinorGridlines"
        Case xlAxisTitle: Id = "AxisTitle"
        Case xlUpBars: Id = "UpBars"
        Case xlDownBars: Id = "DownBars"
        Case xlSeriesLines: Id = "SeriesLines"
        Case xlHiLoLines: Id = "HiLoLines"
        Case xlDropLines: Id = "DropLines"
        Case xlRadarAxisLabels: Id = "RadarAxisLabels"
        Case xlShape: Id = "Shape"
        Case xlNothing: Id = "Nothing"
        Case Else: Id = "Some unknown thing"
    End Select
    MsgBox "Selection type:" & Id
End Sub

 








Related examples in the same category

1.Understanding Chart Events
2.Chart_Deactivate procedure also displays a message only when the chart sheet is deactivated:
3.Events with Chart Sheets
4.Events with Embedded Charts
5.Chart double click event
6.hides the legend when it is double-clicked; double-clicking either axis brings back the legend:
7.zooms in on a left mouse click and zooms out on a right mouse click.
8.Embedded Chart Mouse Events