vba count series in chart in Excel

Q181. In Excel, how can I get the count of number of series in a Chart?

For example, I already have a chart ("Chart1") of Sales data. I want to get the number of series in Chart using VBA?

excel vba count series in chart

To do it in Excel, here is the answer:

  1. Option Explicit
  2. Sub SeriesCount()
  3. Dim lngSeriesCount As Long
  4. lngSeriesCount = ActiveSheet.ChartObjects("Chart1").Chart.SeriesCollection.Count
  5. ''
  6. End Sub

Description:

a) Line 4 - "Chart.SeriesCollection Method" is used to access the properties of the Series.

 

You can find similar Excel Questions and Answer hereunder

1) How to concatenate strings in vba in Excel

2) Excel 2010 vba replacement of application filesearch in Excel

3) How can I export a chart as a gif file?

4) How can I extract file name from a full path including folder path and file name?

5) Vba to return week numbers in Excel

6) How can I save a WorkSheet as a new WorkBook using VBA?

7) How to add a link in a sheet to another sheet

8) Vba clear the contents of an entire sheet in Excel

9) How do I enter a formula in a cell using VBA (using Absolute Reference)?

10) How can I avoid updates to cell values during macro execution?

11) How do I copy a Table from one location to another and retain all formulas, formats and columnwidths?

12) How can I copy and rename a WorkSheet using VBA?

13) How can I add a legend to a chart using VBA?

14) How can I add and link a Chart Title to a cell value?

15) How to change desktop background in Excel