I support an Excel VBA application in my spare-time. I am manufacturing process engineer, not a professional developer.
The charting portions of the applicaiton have worked without issue in Excel 2007. My company is upgrading to Excel 2010 and that same application now has problems with the interaction with the charts on worksheets.
Thie issue is with a bar chart. The application, when reseting, deletes the series from the chart using the code below. I did this so that while new data is being imported / processed there isn't a time where a chart is presented to the user that is not up-to-date with the latest data.
'select the histogram chart
Sheets(sChartSheet).Select
ActiveSheet.ChartObjects("Chart 15").Activate
Call PBarCaption("Delete Existing Histogram Series")
'remove any existing series
For i = 1 To ActiveChart.SeriesCollection.Count
ActiveChart.SeriesCollection(1).Delete
Next i
then creates new series as new data to be charted is imported from an external data file:
'add series for histogram
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).Values = "=HistogramData!$B$5:$B$29"
ActiveChart.SeriesCollection(1).XValues = "=HistogramData!$A$5:$A$29"
ActiveChart.SeriesCollection(1).charttype = xlColumnClustered
The issue with 2010 is that occasionally when the VBA code is ran, the entire bar-chart is 'lost' (deleted) rather than the chart being present without any defined series.
The 'lost' chart seems to happen when concsecutive executions of the base code is performed via another section of VBA code that automatically creates a series of charts and copies them to PowerPoint.
When the sequence of charts is executated manually, it works without issue. When ran automatically, on the generation of the second chating sequence, the chart is getting deleted.
I am hoping that someone is familiar with the changes in the charting from Excel 2007 to 2010 version and will be able to help.
Thanks,
Len