VBA添加辅助轴错误"对象不支持此属性或方法"

时间:2015-03-28 03:58:08

标签: excel vba charts

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

不确定为什么会这样。

2 个答案:

答案 0 :(得分:0)

在使用之前尝试使用SeriesCollection添加其他Sheets(3).ChartObjects("Chart 8") .SeriesCollection.Add

答案 1 :(得分:-4)