Excel Chart系列像素位置

时间:2014-05-20 21:29:48

标签: excel charts shapes

需要:在Excel中,在图表数据源的每次更新中,应使用小圆圈形状突出显示其中一个图表系列的当前终点。

那么,有没有可能找到该系列的位置细节,相应地移动圆圈。

1 个答案:

答案 0 :(得分:1)

您可以用来创建(在模块中):

Public NameOval As String

Sub CirclePt()
    ActiveSheet.ChartObjects("Chart 14").Activate
    x = Selection.Left + ActiveChart.PlotArea.Left

    y = Selection.Top + ActiveChart.PlotArea.Top
    ActiveChart.SeriesCollection(1).Points(ActiveChart.SeriesCollection(1).Points.Count).Select
    x = x + Selection.Left
    y = y + Selection.Top

    ActiveSheet.Shapes.AddShape(msoShapeOval, x - 30, y - 30, 60, 60).Select
    Selection.ShapeRange.Fill.Visible = msoFalse
    NameOval = Selection.Name
End Sub

并在工作表中,移动/更新形状的位置:

Private Sub Worksheet_Change(ByVal Target As Range)
    ActiveSheet.ChartObjects("Chart 14").Activate
    x = Selection.Left + ActiveChart.PlotArea.Left

    y = Selection.Top + ActiveChart.PlotArea.Top
    ActiveChart.SeriesCollection(1).Points(ActiveChart.SeriesCollection(1).Points.Count).Select
    x = x + Selection.Left
    y = y + Selection.Top

    ActiveSheet.Shapes.Range(Array(NameOval)).Select
    Selection.Top = y - 30
    Selection.Left = x - 30
End Sub