VBA Count number of series in a chartObject

爷,独闯天下 提交于 2019-12-02 04:25:20

问题


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?


回答1:


You need to add in Chart:

Debug.Print ThisWorkbook.Sheets("Sheet1").ChartObjects(1).Chart.SeriesCollection.Count



回答2:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!