PDA

View Full Version : Solved: Remove blank series from a chart using VBA ?



Dabo
06-09-2009, 02:03 AM
Hello all,

I'm desperately trying to make a dynamic scatter plot,
To generate it, I first need to clear the source data.
By doing so, I create "blank series" that do a mess in my code.

I would need to write a code to first delete all blank series from my chart, then I will be able to fill my chart.

Thanks in advance

mdmackillop
06-09-2009, 03:28 AM
Please post a sample workbook.

Dabo
06-09-2009, 06:53 AM
Here is the file:

Upper graph : 3 series
Lower graph : 2 series + one blank series because I erased B point's data

How to clean the <blank series> from the graph ?

Thanks !

jolivanes
06-09-2009, 08:34 PM
Dabo.
Would it not be easier to just delete the series with



ActiveChart.SeriesCollection("B").Delete


You can always re-enter it again with something like



With ActiveChart.SeriesCollection.NewSeries
.Name = "B"
.Values = "=ScatterPlot.xls'!B" 'Named Range for series B
With .Border
.ColorIndex = 3
.Weight = xlThin
.LineStyle = xlContinuous
End With
End With


John

Dabo
06-10-2009, 01:09 AM
Perfect,

Your idea work :

first you have to clear the chart (with a macro)
second you have to clear the series' ranges (that's easy)
third you have to input the new series' data

Thanks, it's solved :)

solved !