Indeed charts in 2007 are annoyingly odd in many respects however I couldn't
recreate the problem with the following -
Sub test()
Dim i As Long
Dim rng As Range
Dim cht As Chart
Dim sr As Series
' data in A1

1 & A8

12 (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
Maybe post your own code if fundamentally different. Otherwise try a
DoEvents or should be easy enough to recreate the formula without returning
it from the series object.
Regards,
Peter T
"Brian Murphy" <(E-Mail Removed)> wrote in message
news:61410d23-69ab-4b36-9578-(E-Mail Removed)...
>I have a very old routine which has a problem with SP2 that doesn't
> happen with SP1 or any excel version before 2007.
>
> I use a pair of statements like this to set plotted chart data
> .Item(i).Values = Range(...)
> .Item(i).XValues = Range(...)
>
> Right after this I use
> s = .Item(i).Formula
> to get the formula into a string. The formula string looks ok except
> the spots for XValues and Values are empty. In the debugger I put a
> Debug.Print right before the above statement, and the result has those
> two spots empty. It looks like this:
> =SERIES('Sheet 1'!$C$1,,,1)
> If I set a breakpoint, and rerun the Print statement a second time but
> from inside the Debugger, the full correct formula is printed.
> If I put in Application.ScreenUpdating = True before all this, this
> solves the Formula problem, but makes the macro run horribly slow.
> Excel 2007 already runs this macro way slower than Excel 2003.
>
> Does anyone know anything about this problem, and have any ideas what
> to do about it?
>
> Thanks,
>
> Brian