I would like to delete the empty series on the legend. So far I've 6 seriers and two of them are empty. I got the runtime error - unable to get the legendEntries property of legend code class when running the following codes. It looks like the first empty series went through well but the secomd empty series got the error message. Please help!!!
Sub UpdateChart()
Dim c As Chart: Set c = activechart
Dim i As Integer
Dim a As Variant
c.HasLegend = False
c.HasLegend = True
For i = 1 To 6
a = c.SeriesCollection(i).Values
If WorksheetFunction.Sum(a) = 0 Then
c.Legend.LegendEntries(i).Delete
End If
Next i
End Sub
Sub UpdateChart()
Dim c As Chart: Set c = activechart
Dim i As Integer
Dim a As Variant
c.HasLegend = False
c.HasLegend = True
For i = 1 To 6
a = c.SeriesCollection(i).Values
If WorksheetFunction.Sum(a) = 0 Then
c.Legend.LegendEntries(i).Delete
End If
Next i
End Sub