This VBA script, based off of this tutorial is supposed to update a chart when called. What is catching me is the For loop.
Sub updateChart()
    Dim i As Integer
    Dim lw As Long
    Dim sh As Worksheet
    Dim ws As Chart
    Set sh = Sheet4 'Table
    Set ws = Charts(1) 'Chart
    lw = sh.Range("B" & sh.Rows.Count).End(xlUp).Row
    ws.Activate
    ActiveChart.ChartArea.Select
    ActiveChart.SetSourceData sh.Range(sh.Range("E" & lw & ":N" & lw), sh.Range("E" & lw & ":N" & lw)), xlColumns
    For i = 1 To lw 'Headers to be added (Change if more headers required).
        ActiveChart.SeriesCollection(i).Name = "='Data Input (Updated 9.11.20)'!B" & i + 1
    Next i
    ActiveChart.SeriesCollection(1).Values = "='Data Input (Updated 9.11.20)'!E" & lw & "C1:E" & lw & "N" & lw
End Sub
When running the script, I get
Runtime Error '1004'
Parameter not valid
in the middle of the For loop, when i = 9. There is no difference in the source data at row 9, so I'm unclear why this breaks the loop. The source data is:
