Hi!
I have a problem. I won't to make a chart over som data, but the amount of data is varies from 1 to 100 cells. I have made an if-calculation that returns #N/A for all cells that does'nt contain any valid data.
My problem is that the chart still incluce the cells with #N/A in it, and I can't get the macro for deleting this values to work.
I have tried this macro, but I get an 80004005 run-time error. VB tells me that the error lies in line 8.
Sub DeleteNADataLabels()
Dim s As Series, p As Point
If ActiveChart Is Nothing Then
MsgBox "No chart selected"
Exit Sub
End If
For Each s In ActiveChart.SeriesCollection
If s.DataLabels(7).Type = xlDataLabelsShowValue Then
s.DataLabels.Delete
ActiveChart.ApplyDataLabels xlDataLabelsShowValue
For Each p In s.Points
If p.DataLabel.Text = "#N/A" Then p.DataLabel.Delete
Next
End If
Next
End Sub
Hope somebody could help me. I really need to get this up and going. unfortunately my expirience in programing macros is near zero.
Best regards
Lars
Bookmarks