Repeated calls of Chart.SetSourceData give error 1004

This doesn’t address why the error occurs. This is a workaround.

Before calling SetSourceData, delete all the existing series currently in the chart, and the code will run as expected.

For j = cht.Chart.SeriesCollection.Count To 1 Step -1 
    cht.Chart.SeriesCollection(j).Delete
Next j

I’m not sure why the error occurs in the first place, but this makes it go away.

Leave a Comment