添加新系列无效参数错误

时间:2015-04-01 19:08:57

标签: excel vba

我试图制作图表并添加新系列。我录制了一个宏,然后从中进行了改编。它在开始时工作,但后来我尝试向源添加新数据,并开始抛出无效参数错误。谁能告诉我它有什么问题?谢谢!

行抛出错误如下 ActiveChart.FullSeriesCollection(33).Name = "=Calculation!$B$91"

Sub AllYear() 'Select Data Range for all Charts when selecting All Period

Dim lastColumn As Long
Dim rngV As Range
Dim rngH As Range
Dim rngC As Range
Dim rngX As Range


    With Sheets("QoQ Summary")
            lastColumn = .Cells(5, 5).End(xlToRight).Column

            Set rngV = .Range(.Cells(4, 5), .Cells(36, lastColumn))
            Set rngH = rngV.Offset(38, 0)
            Set rngC = rngH.Offset(38, 0)
            Set rngX = rngC.Offset(38, 0)
            Debug.Print rngV.Address, rngH.Address, rngC.Address, rngX.Address
    End With


    'Video
    Sheets("Dashboard").ChartObjects("Chart 27").Activate
    ActiveChart.SetSourceData Source:=rngV

    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.FullSeriesCollection(33).Name = "=Calculation!$B$91"
    ActiveChart.FullSeriesCollection(33).Values = "=Calculation!$C$91:$H$91"

    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.FullSeriesCollection(34).Name = "=Calculation!$B$92"
    ActiveChart.FullSeriesCollection(34).Values = "=Calculation!$C$92:$h$92"

0 个答案:

没有答案