I'm trying to loop through a range below and get runtime error 1004. The highlighted row is this one here:
ActiveChart.SeriesCollection(i).Values = Worksheets("Chart Help").Range(Cells(10 + j, 5), Cells(10 + j, 1006))
Can anyone tell me what's wrong?
If Worksheets("Chart Help").Cells(4, 9 + j) <> " " Then
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(i).Name = Worksheets("Chart Help").Cells(4, 9 + j)
ActiveChart.SeriesCollection(i).XValues = Worksheets("Chart Help").Range("J5:J1006")
ActiveChart.SeriesCollection(i).Values = Worksheets("Chart Help").Range(Cells(10 + j, 5), Cells(10 + j, 1006))
ActiveChart.SeriesCollection(i).Select
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent6
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.Transparency = 0
End With
i = i + 1
End If
j = j + 1
Cellsproperty. First is row, second column.Cellsrefer to theActiveSheetand not theChart Helpworksheet like you intend. You will need to prefixCellswithWorksheets("Chart Help").Cellsfor it to not error.i? Where is defined or assigned a value?