Excel 2003 VBA方法“单元格”运行时错误

时间:2014-01-28 10:30:17

标签: excel-vba runtime-error excel-2003 vba excel

  

运行时错误'1004':对象'_global'的“cells”方法失败

numShips=7
ActiveChart.SetSourceData Source:=Sheets("Ship Tracker").Range(Cells(2,78),Cells(17, NumShips+80)),_
PlotBy:=xlColumns

为什么我收到此错误。感谢。

1 个答案:

答案 0 :(得分:1)

试试这个(你没有指定Cells()所属的表格):

NumShips = 7
With Sheets("Ship Tracker")
    ActiveChart.SetSourceData Source:=.Range(.Cells(2, 78), .Cells(17, NumShips + 80)), PlotBy:=xlColumns
End With