Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to find the series name using vba?

Tags:

excel

vba

I have written vba code for naming the series in a graph:

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

My problem is that I want to find the particular series name using vba code. In the above code I have two series. Now I want find the series name (manju) by using vba code.

like image 539
M_S_SAJJAN Avatar asked Nov 13 '12 15:11

M_S_SAJJAN


1 Answers

To access the SeriesCollection() by passing the name you can:

MsgBox ActiveChart.SeriesCollection("manju").Name

That's possible because index in the SeriesCollection(index) is actually of Variant type so the compiler works out if you are passing a String type and trying to access it by name or if you are passing a Long/Integer (or any other numeric data type) to access the enumerator.

or iterate the SeriesCollection, comparing the current name against "manju":

For i = 1 to ActiveChart.SeriesCollection.Count
   If ActiveChart.SeriesCollection(i).name = "manju" Then
      MsgBox "Found it!"
      Exit for
   End if
Next
like image 148
Lynn Crumbling Avatar answered Nov 14 '22 22:11

Lynn Crumbling