ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with creating chart within existing worksheet. (https://www.excelbanter.com/excel-programming/349207-problem-creating-chart-within-existing-worksheet.html)

3PhaseMacroMan[_2_]

Problem with creating chart within existing worksheet.
 

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 Whe=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

--
3PhaseMacroMa
-----------------------------------------------------------------------
3PhaseMacroMan's Profile: http://www.excelforum.com/member.php...fo&userid=2994
View this thread: http://www.excelforum.com/showthread.php?threadid=49700


Leith Ross[_443_]

Problem with creating chart within existing worksheet.
 

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


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=497003



All times are GMT +1. The time now is 12:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com