VBA添加辅助轴错误"object doesnt support this property or method"



所以我试图向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"

不确定为什么会发生这种情况。

在使用Sheets(3).ChartObjects("Chart 8") .SeriesCollection.Add之前,尝试添加另一个SeriesCollection

对于三维图表,只有xlPrimary有效。

https://learn.microsoft.com/en-us/office/vba/api/excel.chartgroup.axisgroup

相关内容

最新更新