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.
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