主轴和辅助轴VBA

时间:2017-06-06 14:58:53

标签: excel vba plot

我试图在一张图表上绘制主轴和辅助轴上的两个时间序列,其代码如下:

   Set ARng_1 = range("Annual_Series_1")
   Set MRng_1 = range("Monthly_Series_1")
   Sheet10.ChartObjects("Chart 17").Activate
   With ActiveChart
  .ChartType = xlLineMarkers
  .SeriesCollection.Add Source:=ARng_1
  .SeriesCollection.Add Source:=MRng_1
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Dates"
  .SeriesCollection(1).Axes(xlValue, xlPrimary).HasTitle = True
  .SeriesCollection(2).Axes(xlValue, xlSecondary).HasTitle = True
  .SeriesCollection(1).Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Annual"
  .SeriesCollection(2).Axes(xlValue, xlSecondary).AxisTitle.Characters.Text = "Monthly"
  .Axes(xlCategory).HasMajorGridlines = True
  .SeriesCollection(1).Format.Line.ForeColor.RGB = RGB(255, 0, 0)
  .SeriesCollection(2).Format.Line.ForeColor.RGB = RGB(255, 0, 0)
  .SeriesCollection(1).XValues = Date_Rng
  End With 

我不断收到错误("对象不支持此属性或对象"):

  .SeriesCollection(1).Axes(xlValue, xlPrimary).HasTitle = True

我在这里做错了什么?我是否正确对待轴?我能正确地解决这个问题吗?

感谢!!!!!

1 个答案:

答案 0 :(得分:0)

我认为你的代码就像吼叫......

cancelAnimationFrame