charting run time error, Excel 2007 SP2 problem with SeriesCollection and .Formula property
typo
' data in A1:D1 & A8:D12 (x-values in colA, y's in the rest)
A1:D1 should be A2:D4
so put some data in A2:D4 and A8:d12
Peter T
"Peter T" <peter_t@discussions wrote in message
Sub test()
Dim i As Long
Dim rng As Range
Dim cht As Chart
Dim sr As Series
' data in A1:D1 & A8:D12 (x-values in colA, y's in the rest)
' ActiveSheet.ChartObjects.Delete
On Error GoTo errH
Application.ScreenUpdating = False
Set cht = ActiveSheet.ChartObjects.Add(100, 200, 300, 200).Chart
Set rng = Range("a2:a4")
For i = 1 To 3
Set sr = cht.SeriesCollection.NewSeries
sr.XValues = rng
sr.Values = rng.Offset(, i)
sr.XValues = rng
Debug.Print sr.Formula
Next
Debug.Print
Set rng = Range("A8:A12")
With cht.SeriesCollection
For i = 1 To 3
.Item(i).Values = rng.Offset(, i)
.Item(i).XValues = rng
Debug.Print .Item(i).Formula
Next
End With
done:
Application.ScreenUpdating = True
Exit Sub
errH:
Debug.Print Err.Description
Resume done
End Sub
|