View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ben H Ben H is offline
external usenet poster
 
Posts: 18
Default Check for Data series

Hi all. I have a macro that on the first run through, it will add 2 data
series to the chart it creates. On the second run through, it only adds one.
Is there a way to check if there are 2 data series? The end goal is to
delete the second and unused data series. Here is the function that I use.

Function PlotSigma(strDataName, strChartName, strChartTitle)

With Sheets(strDataName)
Set rng1 = .Range(.Cells(2, 4), _
.Cells(2, 4).End(xlDown))
Set rng2 = .Range(.Cells(2, 3), _
.Cells(2, 3).End(xlDown))
End With

Charts.Add
ActiveChart.ChartType = xlXYScatterSmooth
ActiveChart.Location Whe=xlLocationAsNewSheet, Name:=strChartName
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).Name = Sheets(strDataName).Cells(1, 4)
ActiveChart.SeriesCollection(1).XValues = rng1
ActiveChart.SeriesCollection(1).Values = rng2
end function

Thanks - Ben H.