所以我试图在XYScatter
图中添加一个辅助轴,但我一直收到一个错误,指出对象不支持属性或方法
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlXYScatter
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).Name = "='Sheet2'!$A$9"
ActiveChart.SeriesCollection(1).XValues = "='Sheet2'!$B$9"
ActiveChart.SeriesCollection(1).Values = "='Sheet2'!$C$9"
With Sheets(3).ChartObjects("Chart 8")
.SeriesCollection(1).AxisGroup = xlSecondary ' (Error Occurs here)
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlCategory, xlSecondary) = True
.HasAxis(xlValue, xlPrimary) = True
.HasAxis(xlValue, xlSecondary) = True
.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
.Axes(xlCategory, xlSecondary).CategoryType = xlAutomatic
End With
ActiveChart.SeriesCollection(1).Values = "='Sheet2'!$D$9"
不确定为什么会这样。
答案 0 :(得分:0)
在使用之前尝试使用SeriesCollection
添加其他Sheets(3).ChartObjects("Chart 8") .SeriesCollection.Add
。
答案 1 :(得分:-4)
对于3-D图表,只有xlPrimary有效。
https://docs.microsoft.com/en-us/office/vba/api/excel.chartgroup.axisgroup