Home > OS >  Method "SeriesCollection.Add" failing for a correct input passed
Method "SeriesCollection.Add" failing for a correct input passed

Time:11-30

I am trying to add a new series/legend in my chart via code using the SeriesCollection.Add method, but it throws in Type mismatch error as shown. Documentation says the source argument should be of range type but when given a range, it throws in the error at highlighted line. The same error happens in the SetSourceData method too, which also needs a range input. enter image description here

enter image description here

enter image description here

CodePudding user response:

Your documentation is for Excel.Chart whereas you are working with PowerPoint.Chart.

Based on the documentation of PowerPoint.Chart.SeriesCollection.Add method, you only need to pass the address in string so:

SelChart.SeriesCollection.Add Source:=xRange.Address
  • Related