How to delete a specific LegendEntry?

I

Intuitive Analyst

I have some ("dynamic") charts in Excel 2007 where I'd only like to show
certain legend entries. Specifically I have 2n+k series but only want to
show legend entries for n+k of them. I understand how to use the Delete
method of the LegendEntry object but I don't know how to map the index number
of a given LegendEntry to a particular series. For example, suppose all the
LegendEntries I'd like to delete have the word "blah" in them (obviously it's
something else). How do I loop through the LegendEntries collection to
delete the correct LegendEntry objects? Thanks in advance!
 
A

Andy Pope

Hi,

There is no easy way to do want you describe.

The legend entrys order does not always match the seriescollection
indexing. Within the legend the order is determined by a combination of
the series chart type, axis location and series order.

The help says that the indexing of the legend is purely sequential and
you can not use the name to reference an entry.

Cheers
Andy
 
I

Intuitive Analyst

Thanks for the reply. Too bad that's how it works out; it seems then that
the Delete method is thus nearly useless.
 
A

Andy Pope

Actually for your purpose, which is simply to delete entries, you could
attempt to identify each entry using code.
Say you change the border and or fill for the series to be deleted. You then
scan for those properties in the legend entries and remove when found.

Cheers
Andy
 
I

Intuitive Analyst

Interesting idea, thanks!

Andy Pope said:
Actually for your purpose, which is simply to delete entries, you could
attempt to identify each entry using code.
Say you change the border and or fill for the series to be deleted. You then
scan for those properties in the legend entries and remove when found.

Cheers
Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top