Newseries; macro to code

C

cate

Like a lot of stuff I do the macro thing first to get a general idea
of the landscape. Here I'm up against the limits of my ability.

This has been working just fine for a while

myChart.SeriesCollection.NewSeries
myChart.SeriesCollection(2).Values = "='HCLHotBath'!
R75C107:R75C250"
myChart.SeriesCollection(2).Name = "B2Alpha"

Now, all of a sudden it bombs on the .Name =, the message is

"Unable to set the Name property of the Series Class"

I have this feeling that SeriesCollection(2) really isn't there. But,
on the other hand, the values plotted. I can see it. I would think
there would be a way to create a series object and THEN add it to the
chart somehow.

(Seems a little flaky to rely on NewSeries returning the "next"
number. What if someone altered the code above later.)

Thank you.
 
P

p45cal

cate;591297 said:
Like a lot of stuff I do the macro thing first to get a general idea
of the landscape. Here I'm up against the limits of my ability.

This has been working just fine for a while

myChart.SeriesCollection.NewSeries
myChart.SeriesCollection(2).Values = "='HCLHotBath'!
R75C107:R75C250"
myChart.SeriesCollection(2).Name = "B2Alpha"

Now, all of a sudden it bombs on the .Name =, the message is

"Unable to set the Name property of the Series Class"

I have this feeling that SeriesCollection(2) really isn't there. But,
on the other hand, the values plotted. I can see it. I would think
there would be a way to create a series object and THEN add it to the
chart somehow.

(Seems a little flaky to rely on NewSeries returning the "next"
number. What if someone altered the code above later.)

Thank you.

Assign the new series a variable name, then use that to refer to it:

Code
 
C

cate

cate;591297 Wrote:


Like a lot of stuff I do the macro thing first to get a general idea
of the landscape.  Here I'm up against the limits of my ability.
This has been working just fine for a while
myChart.SeriesCollection.NewSeries
myChart.SeriesCollection(2).Values = "='HCLHotBath'!
R75C107:R75C250"
myChart.SeriesCollection(2).Name = "B2Alpha"
Now, all of a sudden it bombs on the .Name =, the message is
"Unable to set the Name property of the Series Class"
I have this feeling that SeriesCollection(2) really isn't there.  But,
on the other hand, the values plotted.  I can see it.  I would think
there would be a way to create a series object and THEN add it to the
chart somehow.
(Seems a little flaky to rely on NewSeries returning the "next"
number.  What if someone altered the code above later.)
Thank you.

Assign the new series a variable name, then use that to refer to it:

Code:
--------------------
    Set NewSeries = mychart.SeriesCollection.NewSeries
  NewSeries.Values = "='HCLHotBath'!R75C107: R75C250"
  NewSeries.Name = "B2Alpha"

--------------------

--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: 558
View this thread:http://www.thecodecage.com/forumz/showthread.php?t=163861

Microsoft Office Help

Thank you. One more question. How would you 'tag' this new series.
Say the chart object got passed and I wanted to access this, or other,
speicific series there.
 
P

p45cal

cate;591578 said:
Thank you. One more question. How would you 'tag' this new series.
Say the chart object got passed and I wanted to access this, or other,
speicific series there.

Well you've just named it so you can refer to it by that, but reliabl
only if you've *not *named two or more series with the same name, wit
the likes of:
myChart.SeriesCollection("B2Alpha")
otherwise it'll choose the first series of that name it comes across
 

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