0
votes

run-time error '1004': "cells" method of object '_global' failed

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

Why did I get this error. Thanks.

1

1 Answers

1
votes

Try this one (you haven't specify sheet to which Cells() belongs):

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