In sheets("Cost"), there is an error commented in the code below. Once the error is resolved, I plan to put a 'c(x)' counter to loop through each chart
Run-time error '1004': Method 'Range' of object '_Worksheet' failed
I think the error has something to do with how I am referencing the other sheet
Dim p As Worksheet, cost As Worksheet
Set cost = Workbooks("dashboard.xlsm").Worksheets("Cost")
Set p = Workbooks("dashboard.xlsm").Worksheets("p")
Dim c(1 To 3) As Variant
p.Activate
'[c(x)] denotes ranges for each chart object
'modified by counter [i], denoting ranges for each series
Set c(1) = p.Range(Cells(3, 1 + i), Cells(3, 1 + i).End(xlDown))
Set c(2) = p.Range(Cells(3, 4 + i), Cells(3, 4 + i).End(xlDown))
Set c(3) = p.Range(Cells(3, 8 + i), Cells(3, 8 + i).End(xlDown))
cost.Activate
For i = 1 To 2
With ActiveSheet.ChartObjects("Chart 1").Chart.SeriesCollection(i)
'all charts follow same time series
.XValues = p.Range(Range("a3"), Range("a3").End(xlDown)) '**error here**
.Values = c(1)
End With
Next i