VBA return all objects

M

mark1

I am trying to use an if...then statement to show a
message box. I want to say "if the chart legend contains
this legend entry, then show MessageBox X." What I need
is a way to include all legend entries in my if...then
statement, instead of referencing each one seperately. In
the example below, instead of "...LegendEntries
(1).Font..." I want something like "...LegendEntries
(all).Font..." Is there a way to do this? Many thanks!!

Worksheets("sheet1").ChartObjects(1).Chart _
.Legend.LegendEntries(1).Font.Italic = True
 
R

Rollin_Again

How about using some type of loop with your single IF statement.



Public sub Find_Legend()

Sheets("Sheet1").Select

ActiveChart.Select

For i = 1 To ActiveChart.SeriesCollection.Count

If ActiveChart.SeriesCollection(i).Name = "My Legend Entry" Then
MsgBox (ActiveChart.SeriesCollection(i).Name & " Has Been Found")
End If

Next

End Sub



Rolli
 
Top