Bar graph w/ no value (#N/A)

A

Aimee

I am creating a graph using bars and would like to include
the values on the bar. However, if the value is #N/A, an
extraneous "#N/A" is displayed on the graph. Is there any
way to suppress this?
 
J

Jon Peltier

Aimee -

This macro removes #N/A and zero from the datalabels in the active chart:

Sub OutNA()
Dim mySrs As Series
Dim myPt As Point
Dim myLbl As DataLabel
Dim iPtIx As Integer
Dim iPtCt As Integer
For Each mySrs In ActiveChart.SeriesCollection
iPtCt = mySrs.Points.Count
For iPtIx = iPtCt To 1 Step -1
If mySrs.DataLabels(iPtIx).Text = "#N/A" Then
mySrs.DataLabels(iPtIx).Text = ""
ElseIf mySrs.Values(iPtIx) = 0 Then
mySrs.DataLabels(iPtIx).Text = ""
End If
Next
Next
End Sub

- Jon
 

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