Some years ago I wrote an Excel routine to add totals to a stacked column chart which adds a zero-value series to the chart and then deletes the legend entry for the new series using, in effect, ActiveChart.Legend.LegendEntries(ActiveChart.SeriesCollection.Count).Delete.
I am now updating this for Excel 2010 and am having a problem because Microsoft have changed the way the legend entries are indexed if the legend is to the right (or left) of the chart: in this situation the above code now deletes the legend entry relating to the first series rather than the last! If, however, the legend is at the bottom of the chart, the above code works fine as the legend entries are indexed in the opposite, and usual, order (ie, LegendEntries(1) relates to SeriesCollection(1) etc).
If the legend is in its automatic position, then I can read this and react accordingly, but unfortunately my users cannot be relied upon to leave things alone, so I was hoping to find a property to at least tell me the orientation of the legend, regardless of where it actually is, but I can't find one.
I have read Jeffrey Smith's thread on Removing Legend Entries with VBA but, unfortunately, his code also deletes the wrong legend entry in the above scenario.
Any suggestions as to how I can get round this will be much appreciated.
(I first posted this question to answers.microsoft.com, but have had no responses as yet.)
I am now updating this for Excel 2010 and am having a problem because Microsoft have changed the way the legend entries are indexed if the legend is to the right (or left) of the chart: in this situation the above code now deletes the legend entry relating to the first series rather than the last! If, however, the legend is at the bottom of the chart, the above code works fine as the legend entries are indexed in the opposite, and usual, order (ie, LegendEntries(1) relates to SeriesCollection(1) etc).
If the legend is in its automatic position, then I can read this and react accordingly, but unfortunately my users cannot be relied upon to leave things alone, so I was hoping to find a property to at least tell me the orientation of the legend, regardless of where it actually is, but I can't find one.
I have read Jeffrey Smith's thread on Removing Legend Entries with VBA but, unfortunately, his code also deletes the wrong legend entry in the above scenario.
Any suggestions as to how I can get round this will be much appreciated.
(I first posted this question to answers.microsoft.com, but have had no responses as yet.)