Excel 2007 ActiveChart formatting erases graph

M

Mbballfan

I'm converting some Excel 2003 macro to 2007. In the charting part, it bombs
because only blank graphs are displayed. After stepping thru it I realize
that the data disappears whenever I do any formatting. Attached is code
snippet. I moved setting the .Values and .XValues at the bottom and seems to
work. What is the general rule? Are we allowed to change the format on the
activeChart after we populate it with data?

Thanks

With ActiveChart
For split_n = 1 To ser_cnt
Set X_rng = Range(chD.Cells(splits(split_n).spR1, chD_c),
chD.Cells(splits(split_n).spR2, chD_c))
Set Y_rng = Range(chD.Cells(splits(split_n).spR1, chD_c + 1),
chD.Cells(splits(split_n).spR2, chD_c + 1))
If Application.Count(Y_rng) > 0 Then
ser_n = ser_n + 1
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(ser_n).Values = Y_rng
ActiveChart.SeriesCollection(ser_n).XValues = X_rng
ActiveChart.SeriesCollection(ser_n).Name = splits(split_n).spName
With .SeriesCollection(ser_n)
.MarkerStyle = marker(split_n).mrStyle
.MarkerForegroundColorIndex = marker(split_n).mrForeground
.MarkerBackgroundColorIndex = marker(split_n).mrBackground
.MarkerSize = marker(split_n).mrSize - cht_mrkr
With .Border
.LineStyle = xlContinuous
.ColorIndex = marker(split_n).mrBorderColor
End With
If matrix(4).mxValue = "LIN" Then
.Trendlines.Add Type:=xlLinear
If isEXISTbyOBJ(.Trendlines(1)) = True Then
With .Trendlines(1).Border
.ColorIndex = marker(split_n).mrBorderColor
.Weight = xlHairline
End With
End If
ActiveChart.Legend.LegendEntries(ser_n + 1).Delete
End If
End With
End If
Next
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top