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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With