Catch event on chart click

前端 未结 4 1218
谎友^
谎友^ 2020-12-18 10:39

I need to catch event in Excel VBA when I click on the chart.

I want to bring the chart to the front, when it is activated, but I can\'t find an appropriate event.

4条回答
  •  时光说笑
    2020-12-18 11:12

    Create a handler in the worksheet:

    Public Sub ChartSelected(ByVal Name As String)
      Me.ChartObjects(Name).BringToFront
    End Sub
    

    Right-click the chart and select Assign macro, then type something like

    'Sheet1.ChartSelected "Chart 1"'

    where Chart 1 is the name of the chart.

    To assign this handler programmatically, use

    ChartObject.OnAction = "'Sheet1.ChartSelected ""Chart 1""'"
    

提交回复
热议问题