2014-05-20 4 views
0

필요 : Excel에서 차트의 데이터 소스가 업데이트 될 때마다 차트 계열 중 하나의 현재 끝점이 작은 원 모양으로 강조 표시되어야합니다.Excel 차트 시리즈 픽셀 위치

그렇다면 해당 시리즈의 위치 세부 정보를 찾아서 원을 따라 이동할 가능성이 있습니까?

+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