How to find the name of a series using vba?

I wrote vba code to indicate the series in the graph:

ActiveChart.SeriesCollection(1).name = "SPEC" ActiveChart.SeriesCollection(2).name = "manju" 

My problem is that I want to find the name of a specific series using the vba code. In the above code, I have two series. Now I want to find the series name (manju) using vba code.

+6
source share
1 answer

To access SeriesCollection() by passing a name, you can:

 MsgBox ActiveChart.SeriesCollection("manju").Name 

This is possible because the index in SeriesCollection(index) is actually of type Variant , so the compiler works if you pass the String type and try to access it by name or if you pass Long/Integer (or any other type of numeric data) to access the counter.

or repeat the SeriesCollection series, comparing the current name with manju:

 For i = 1 to ActiveChart.SeriesCollection.Count If ActiveChart.SeriesCollection(i).name = "manju" Then MsgBox "Found it!" Exit for End if Next 
+9
source

All Articles