FullSeriesCollection问题

时间:2017-06-08 08:54:23

标签: excel vba plot

我使用以下代码绘制图表:

Set Date_Rng = range("Time_Series_Dates_1")

Set Rng_1 = range("Time_Series_1")
Sheet10.ChartObjects("Chart 2").Activate
With ActiveChart
  .SeriesCollection.Add Source:=Rng_1
   .ChartType = xlLineMarkers
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Dates"
  .Axes(xlValue, xlPrimary).HasTitle = True
  .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "£ GDP"
  .Axes(xlCategory).HasMajorGridlines = True
  .SeriesCollection(1).Format.Line.ForeColor.RGB = RGB(255, 0, 0)
  .SeriesCollection(1).XValues = Date_Rng
 End With  

然后我尝试执行以下操作:

           Selection.Formula = _
    "=SERIES(,'Tool v13.xlsm'!Time_Series_Dates_1,'Tool v13.xlsm'!Time_Series_1,1)"

我得到一个对象定义的错误!我做错了什么?  我试过这个:

  With ActiveChart
   .SeriesCollection.NewSeries
   .FullSeriesCollection(1).Values = _
    "=='Tool v13.xlsm'!Time_Series_1"

   .ChartType = xlLineMarkers
  .Axes(xlCategory, xlPrimary).HasTitle = True
  .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Dates"
  .Axes(xlValue, xlPrimary).HasTitle = True
  .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "£ GDP"
  .Axes(xlCategory).HasMajorGridlines = True
  .SeriesCollection(1).Format.Line.ForeColor.RGB = RGB(255, 0, 0)
  .SeriesCollection(1).XValues = Date_Rng
 End With

但没有运气。我的命名范围可能有什么问题吗?

0 个答案:

没有答案