View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default How to add series to a chart using a macro

Sorry, I didn't read far enough. Stand by.

" wrote:

I am getting the following error for executing this code

Unable to get the chart object property of the worksheet class

Please help me solve the problem.

I am trying to add 240 series to a chart. If someone can help to add
10 series then I will tweak the code for 240 series. Please help.

Code:

Dim mySeries As Series
For i = 6 To 240
j = ((i - 3) * 524) + 46
k = j + 523


Set mySeries = Sheets("Sheet1").ChartObjects("Chart1"). _
Chart.SeriesCollection.NewSeries


mySeries.SeriesCollection(i).XValues = "='Sheet1'!R46C3:R569C3"
mySeries.ChartObjects("Chart 1").SeriesCollection(i).Values =
"='Sheet1'!R(j)C1:R(k)C1"
mySeries.ChartObjects("Chart 1").SeriesCollection(i).Name =
"='Sheet1'!R(j)C2"

Next