PDA

View Full Version : Solved: Legend.LegendEntries issue - Object doesn't support



Salient
07-03-2012, 04:52 PM
With ActiveChart
For i = .Legend.LegendEntries.Count To 1 Step -1
If .Legend.LegendEntries(i).Value <> "Sprung" And .Legend.LegendEntries(i).Value <> "Weight" Then
.Legend.LegendEntries(i).Delete
End If
Next i
End With


Am receiving an error on the .Legend.LegendEntries(i).Value line

"Object doesn't support this property or method"

Not sure where to go with this from here, Excel 2010 btw.

Big help needed.

Kenneth Hobs
07-03-2012, 05:26 PM
Try Activate and then Select.

ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Values = "=Sheet1!R5C3:R5C11"
ActiveChart.SeriesCollection(1).Name = "=Sheet1!R5C2"

Salient
07-03-2012, 10:47 PM
Have advance this one ...


With ActiveChart
For i = .SeriesCollection.Count To 1 Step -1
If .SeriesCollection(i).Name <> "Sprung" And SeriesCollection(i).Name <> "Frame" Then
.Legend.LegendEntries(i).Delete
End If
Next i
End With


Now falling over when I try to delete the legend entry :(

Salient
07-04-2012, 06:38 PM
Further to this one, it actually works if all the legendEntries are on display but falls over if a legend isn't currently displayed, i.e not enough room to show in the legend box.

And no increasing the legend box size isn't an option.

Checking around the net for similar issues that spill some light on this one.

Edit : "On Error Resume Next" has strangely resolved this one ???? Executes the delete successfully, another wonderfully weird Microsoft thing.

Kenneth Hobs
07-05-2012, 05:30 AM
IF you can not post your workbook, make an example that has the problem and attach that one.