If the data is properly arranged, you could use SetSourceData and change the
entire data range. This wouldn't hose any series that still have proper
data; it adds new series if the range expands, and removes series if the
range contracts.
- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. -
http://PeltierTech.com
_______
"Fermon" wrote in message
...
Hi,
I have an Excel file that reads data from an external source and creates
an
X-Y chart from the data. Each time the data is read, the number of rows is
different and I need to delete the old data. The chart is created in such
a
way that each row is a new series.
In order to delete the old data I have simple loop that goes like this:
For i = 4 To ActiveChart.SeriesCollection.Count
ActiveChart.SeriesCollection(ActiveChart.SeriesCol lection.Count).Delete
Next i
I want to keep the first three series intact all the time.
The problem I have is that if for whatever reason there are any <empty
series in the chart, where the chart has a series pointing to cell that
have
been cleared, the Delete method fails and I cannot delete the series using
VBA. I have to delete them manually.
Is there a way I can circumvent this and be able to delete the series with
VBA anyway?
Thanks for your help!!
Fermon
P.S. The real simple answer is to delete the series before I update the
chart, but my users need to have access to the data in the chart and they
could delete some cells to run different scenarios. So this is still a
problem for me...