excelvbachartsdatasourceexcel-charts

Chart SetSourceData fails - Object doesn't support this property or method


The following statement fails:

wksGraphTotal.ChartObjects("TotQuestion").SetSourceData Source:=wksGraphTotal.Range("$A$2:$C$62")

Object doesn't support this property or method

But if I click on the chart and choose "Select Data" in the Excel ribbon, I can set the Chart data range to ='Graph Total'!$A$2:$C$62 without a problem.

What am I doing wrong?


Solution

  • This will work.

    wksGraphTotal.ChartObjects("TotQuestion").Chart.SetSourceData Source:=wksGraphTotal.Range("$A$2:$C$62")