Problem adding Series XValues to Chart using VBA
I have an intermittent and vexing problem trying to add new series to a Chart
using Excel 2002 VBA. Here's a snippet: For i = 1 To NumSeries DataCol = ChartData(k).SeriesParam(i).DataCol Set rgY = Sheets("Appointment Efficiency").Range(ActiveSheet.Cells(StartRow, DataCol), ActiveSheet.Cells(ActiveRow, DataCol)) Set rgX = Sheets("Appointment Efficiency").Range(ActiveSheet.Cells(StartRow, 2), ActiveSheet.Cells(ActiveRow, 2)) scSeries.NewSeries scSeries(i).XValues = rgX scSeries(i).Values = rgY scSeries(i).Name = ChartData(k).SeriesParam(i).SeriesName This crashes with a Runtime Error : "Method 'XValues' of Object 'Series' failed" *most* of the time. Sometimes it runs fine. When it crashes, Excel hangs and I have to kill it. I have tried all variants of the range object for the X values, including just typing a static range for testing. A little more background - the chart already exists, and I delete existing series from it before adding the new ones back. The YValues add fine if I just comment out the XValues line. Everything else works great - point labels, line types, etc all set using VBA. Any help/suggestions would be much appreciated. Thanks, Sean |
All times are GMT +1. The time now is 02:29 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com