View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Thulasiram[_2_] Thulasiram[_2_] is offline
external usenet poster
 
Posts: 106
Default How to add series to a chart using a macro

On Oct 19, 7:19 am, JLGWhiz wrote:
Well, I tried to find something that was directly related to what you are
attempting and did not do very well at it. However, I did find a site that
gives a lot of references for charting and using VBA to do so. Here is the
site address:

http://www.contextures.com/charts.html

" 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


Thanks. I fixing most of my part but still facing errors in this part

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"

R(j)C1:R(k)C1 and R(j)C2 declaration are ok?