ehcpieterse
Active Member
- Joined
- Nov 16, 2006
- Messages
- 278
hi, i am experiencing a seemingly strange error.
i have written a small piece of code to add data labels to a scatter plot (code below)
Sub ScatterLabels()
ActiveSheet.ChartObjects("Chart 1").Activate
For i = 1 To 42
ActiveChart.SeriesCollection(1).Points(i).DataLabel.Text = ActiveSheet.Cells(i + 1, 1).Value
Next i
ActiveSheet.ChartObjects("Chart 2").Activate
For i = 1 To 42
ActiveChart.SeriesCollection(1).Points(i).DataLabel.Text = ActiveSheet.Cells(i + 1, 1).Value
Next i
End Sub
This code works 100%, however, a different piece of code (below) on another sheet for a similar graph give s me the following error: "Method 'DataLabel' of object 'Point' failed". To me the code should work, but obviously i'm missing something.
Sub ScatterLabels2()
ActiveSheet.ChartObjects("Chart 2").Activate
For i = 1 To 42
ActiveChart.SeriesCollection(1).Points(i).DataLabel.Text = "ABC"
Next i
End Sub
i have written a small piece of code to add data labels to a scatter plot (code below)
Sub ScatterLabels()
ActiveSheet.ChartObjects("Chart 1").Activate
For i = 1 To 42
ActiveChart.SeriesCollection(1).Points(i).DataLabel.Text = ActiveSheet.Cells(i + 1, 1).Value
Next i
ActiveSheet.ChartObjects("Chart 2").Activate
For i = 1 To 42
ActiveChart.SeriesCollection(1).Points(i).DataLabel.Text = ActiveSheet.Cells(i + 1, 1).Value
Next i
End Sub
This code works 100%, however, a different piece of code (below) on another sheet for a similar graph give s me the following error: "Method 'DataLabel' of object 'Point' failed". To me the code should work, but obviously i'm missing something.
Sub ScatterLabels2()
ActiveSheet.ChartObjects("Chart 2").Activate
For i = 1 To 42
ActiveChart.SeriesCollection(1).Points(i).DataLabel.Text = "ABC"
Next i
End Sub