Question

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.

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top