The appended snippet is from a chart-plotting routine I use.
If the technology is working, the significant bit should be marked up in red and emboldened...
Crucially, to get a blank, you have to activate the label and blank it. I guess you can use any test you like: my problem was an incomplete data set (xVals) where the entry might be zero or simply left empty.
Hope there is something here which you can use.
Alf
' For each cell in the range xVals...
For Each xCell In Range(xVals)
On Error GoTo ErrorHandler
[red]If IsEmpty(xCell) = True Or xCell = "0" Then
ActiveChart.SeriesCollection(1).Points(Counter).Ha sDataLabel = True
ActiveChart.SeriesCollection(1).Points(Counter).Da taLabel.Text = ""[/ red] GoTo SkipBlankValue 'skip empty cells
End If
If xCell.Offset(0, SetOff) = "" Or xCell.Offset(0, SetOff) = "0" Then
ActiveChart.SeriesCollection(1).Points(Counter).Ha sDataLabel = True
ActiveChart.SeriesCollection(1).Points(Counter).Da taLabel.Text = ""
GoTo SkipBlankValue
End If
' Get the value of the label next to the current x-value.
xLabel = Left$(xCell.Offset(0, -1).Value, 1) & Left$(xCell.Offset(0, -2).Value, 1)
' Attach a label to the current data point in the chart.
Sheets(ThisChart).Activate
ActiveChart.SeriesCollection(1).Points(Counter).Ha sDataLabel = True
' Put the text (initials) into the attached
' label.
ActiveChart.SeriesCollection(1).Points(Counter).Da taLabel.Text = xLabel
SkipBlankValue:
' Increment the counter.
Counter = Counter + 1
Next xCell 'loop until all done
|