View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
[email protected] ucanalways@gmail.com is offline
external usenet poster
 
Posts: 115
Default How to add series to a chart using a macro

On Oct 19, 7:51 am, "Dana DeLouis" wrote:
Hi. Are you using Excel 2007?
The last three loops give Rows above 64k.

Sub test()
For i = 238 To 240
j = ((i - 3) * 524) + 46
k = j + 523
Debug.Print j; k
Next
End Sub

123186 123709
123710 124233
124234 124757

If I did this correctly, maybe:

For TopRow = 1618 To 124234 Step 524
BottomRow = Toptow + 523

Your code part:

"='Sheet1'!R(j)C1:R(k)C1"


Here, j & k are part of a string. Vba doesn't know to replace "j" with the
value j.

Maybe you could work something like this idea into your code:

For r = 1618 To 124234 Step 524
StrAddress = Cells(r, 1).Resize(524, 1).Address(False, False)
' Do Stuff...
Next r

--
Dana DeLouis
Windows XP & Excel 2007

wrote in message

ups.com...

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


Dana, with your for loop, how to modify these two lines in the code..
rest seems ok for me.

First line, i have j and k and second line I have j. Please let me
know if will your code fit into mine? Kind of spilliting my hair here!


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"

I think someone else is on the boat.