Catch event on chart click

前端 未结 4 1231
谎友^
谎友^ 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 10:55

    Real easy. Put this VBA procedure into a regular code module:

    Sub ClickChart()
      ActiveSheet.ChartObjects(Application.Caller).BringToFront
    End Sub
    

    Assign the macro ClickChart to all charts you want to have this behavior.

    When you click any of the charts, it gets moved in front of all others on the sheet.

    After posting, I see that @timwilliams has suggested this in a comment to another answer.

提交回复
热议问题