在图表中,每个系列都有系列值。
当系列值绘制在图表上就成了数据点,有多少个系列值,就有多少个系列点。
在vba中Point对象代表图表系列的数据点,图表系列的所有数据点组成了Points集合对象。
在系列的最左边的数据点位于Points集合对象的索引值1,在系列最右边的数据点位于Points集合对象的索引值 Points.Count。
以下的代码举例说明了如何遍历操作图表中某个系列的数据点Point对象:
Sub QQ1722187970()
Dim oWK As Worksheet
Set oWK = Excel.ActiveSheet
'内嵌在工作表的图表对象
Dim oChartObject As ChartObject
Set oChartObject = oWK.ChartObjects(1)
'图表对象
Dim oChart As Chart
Set oChart = oChartObject.Chart
'图表系列对象
Dim oSeries As Series
'图表数据点对象
Dim oPoint As Point
'图表数据点集合对象
Dim oPoints As Points
With oChart
Set oSeries = .SeriesCollection(1)
With oSeries
Set oPoints = .Points
For Each oPoint In oPoints
With oPoint
'数据点的名称
Debug.Print .Name
End With
Next
End With
End With
End Sub


发表评论