I know this seems straightforward but it doesn't seem to work for me. I have a chart on "Sheet1". It is the only chart on the sheet. I want to get the number of series in the chart. So I use:
Debug.Print ThisWorkbook.Sheets("Sheet1").ChartObjects(1).SeriesCollection.Count
to get the answer in the immediate window. However VBA gives me a "Object doesn't support property or method" error. Any ideas?
You need to add in Chart
:
Debug.Print ThisWorkbook.Sheets("Sheet1").ChartObjects(1).Chart.SeriesCollection.Count
Try this Debug.Print ThisWorkbook.Sheets("Sheet1").ChartObjects(1).Chart.SeriesCollection.Count
来源:https://stackoverflow.com/questions/13363812/vba-count-number-of-series-in-a-chartobject