Problem with creating chart within existing worksheet.

3

3PhaseMacroMan

Hi all,

Essentially I have an existing worksheet with data and would like t
create charts from that data and place the charts on this sheet. Whe
attempting to run my code, I get an "Automation Error". Here is a
excerpt of my code that is currently problematic:

If Location1_1 > 0 Then
Set case9 = wb.Charts.Add
With case9
.ChartType = xlXYScatterSmooth
.Location Where:=xlLocationAsObject, Name:="DataSet 1"

.SeriesCollection.NewSeries
Set Cycles = SetRange(page1, 3, 62, 8)
.SeriesCollection(1).Xvalues = Cycles
.SeriesCollection(2).Xvalues = Cycles

Set YValues = SetRange(page1, 3, 62, 9)
.SeriesCollection(1).Name = "V1"
.SeriesCollection(1).Values = YValues

.SeriesCollection.NewSeries
.SeriesCollection(2).Name = "I1"
Set YValues = SetRange(page1, 3, 62, 10)
.SeriesCollection(2).Values = YValues
.SeriesCollection(2).AxisGroup = 2

<formatting statements>

End With
End If
End Sub


The compiler highlights the line ".SeriesCollection.NewSeries" as th
source of the error.

Any help would be greatly appreciated.

Thanks
 
L

Leith Ross

Hello 3PhaseMacroMan,

Unless your system is different, SeriesCollection is a method that
requires an index arugument...

EXAMPLE 1:
..SeriesCollection(1)

This returns a single series. To return all the seiries in a chart
use...

EXAMPLE 2:
..SeriesCollection

If NewSeries is a numeric index then use example 1.

Sincerely,
Leith Ross
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top