Hi ker9,
Good progress.
Some of the problems include:
a. Data Series missing
b. Data point missing
c. Data label missing (if point is missing)
d. Data label text is not a number (improbable but possible)
Start deleting things one at a time until you get a runtime error. Then when you find which runtime errors you get you can process or ignore the possible errors.
For example you could use something like this as a starting point.
Sub MainRoutine()
'...
s1p1 = GetDataLabelAsLongInteger(6, 1)
s1p2 = GetDataLabelAsLongInteger(6, 2)
'...
End Sub
Function GetDataLabelAsLongInteger(iSeriesNumber As Integer, iPointNumber As Integer) As Long
Dim iError As Long
On Error Resume Next
GetDataLabelAsLongInteger = CLng(ActiveChart.SeriesCollection(iSeriesNumber).Points(iPointNumber).DataLabel.Text)
iError = Err.Number
Select Case iError
Case 0
'do nothing - no error
Case 1004
'Method 'SeriesCollection' of object '_Chart' Failed'
'Stop, ignore, or perform automatic corrective action as required
Debug.Print "Series " & iSeriesNumber & " Point " & iPointNumber & " Runtime Error " & iError
Case Else
'Stop, ignore, or perform automatic corrective action as required
Debug.Print "Series " & iSeriesNumber & " Point " & iPointNumber & " Runtime Error " & iError
End Select
On Error GoTo 0
End Function
Lewis
Bookmarks