2014-05-20 50 views
0

需要:在Excel中,在圖表Data Source的每次更新時,圖表系列之一的當前端點應以小圓形Shape突出顯示。Excel Chart系列像素位置

因此,是否有可能找到該系列的位置細節,以相應地移動圓圈。

+0

好像可能具有類似的效果,但更容易改變最後一個數據點的格式。 – pnuts

回答

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