VBA计数图表对象中的系列数 [英] VBA Count number of series in a chartObject

查看:290
本文介绍了VBA计数图表对象中的系列数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这似乎很简单,但对我来说似乎不起作用。
我在Sheet1上有一个图表。它是纸上唯一的图表。我想得到图表中的系列数。所以我使用:

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

在立即窗口中获得答案。但是VBA给了我一个对象不支持属性或方法的错误。任何想法?

解决方案

您需要添加 Chart p>

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


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

这篇关于VBA计数图表对象中的系列数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆