![]() |
Excel 2007 ActiveChart formatting erases graph
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 |
All times are GMT +1. The time now is 02:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com