Sub 차트추세선수식()
Range("B21:C24").Select
ActiveSheet.Shapes.AddChart2(240, xlXYScatterSmooth).Select
ActiveChart.SetSourceD
ata Source:=Range("Sheet1!$B$21:$C$24")
ActiveChart.FullSeriesCollection(1).Select
ActiveChart.FullSeriesCollection(1).Trendlines.Add
ActiveChart.FullSeriesCollection(1).Trendlines(1).Select
With Selection
.Type = xlPolynomial
.Order = 2
End With
Selection.Intercept = 0
Selection.DisplayEquation = True
ActiveChart.SeriesCollection(1).Trendlines(1).DataLabel.Select
Selection.NumberFormat = "#,##0.00000000000000000000_);Red"
[B27] = ActiveChart.SeriesCollection(1).Trendlines(1).DataLabel.Text
End Sub
위 코드를 이용하여 Sheet1의 B21:C24에 있는 데이터를 이용하여 차트를 만들고 차트의 그래프 추세선식을 불러와 B27 셀에 그 수식을 입력하는 코드입니다.
이 코드가 엑셀 2010 버전에서는 실행되는데 2016버전에서는 B27셀로 차트의 그래프 추세선 수식을 불러오는 항목이 실행되지 않아 문의 드립니다.
2016버전에서도 코드를 한줄한줄 실행시키면 잘되는데"차트추세선수식" 매크로명으로 실행을 시키면 B27셀로 차트의 그래프 추세선 수식을 불러오는 코드가 수행되지 않습니다.
즉 [B27] = ActiveChart.SeriesCollection(1).Trendlines(1).DataLabel.Text 이 항목이 수행되지 않습니다.
이럴 때 어떻게 해야하는지 문의 드립니다.