I keep getting a "subscript out of range" error on the If statement. I've tried changing the start index to 0 and 1 and it still had this error.
Sorry the codes messy, part of the reason I've been messing around with a lot of different ways to declare the array.
I'm trying to alter values of a chart Series without messing up the data I have down. I'm trying to do this by setting the series arrays of the data ranges and then changing the elements. Problem is I can't figure out how to iterate through the arrays and change the values, it says I'm out of bounds?
Dim ColumnData() As Variant, c As Chart, s As Series, g As Integer
ReDim ColumnData(EndNumber - StartNumber)
g = 1
Set c = ActiveChart
For i = 20 To 29
Set s = c.SeriesCollection(g)
ColumnData = Range(Cells(StartNumber, i), Cells(EndNumber, i))
s.Values = ColumnData
For j = LBound(ColumnData, 1) To UBound(ColumnData, 1) - 1
If ColumnData(j) = 5 Then
ColumnData(j) = 4
End If
Next j
g = g + 1
Next i
Sorry the codes messy, part of the reason I've been messing around with a lot of different ways to declare the array.
I'm trying to alter values of a chart Series without messing up the data I have down. I'm trying to do this by setting the series arrays of the data ranges and then changing the elements. Problem is I can't figure out how to iterate through the arrays and change the values, it says I'm out of bounds?
Dim ColumnData() As Variant, c As Chart, s As Series, g As Integer
ReDim ColumnData(EndNumber - StartNumber)
g = 1
Set c = ActiveChart
For i = 20 To 29
Set s = c.SeriesCollection(g)
ColumnData = Range(Cells(StartNumber, i), Cells(EndNumber, i))
s.Values = ColumnData
For j = LBound(ColumnData, 1) To UBound(ColumnData, 1) - 1
If ColumnData(j) = 5 Then
ColumnData(j) = 4
End If
Next j
g = g + 1
Next i