Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Problem with setting values for SeriesCollection

Your code worked for me. Is txtPartNum always a valid sheet name? You
might try enclosing it in single quotes:

..SeriesCollection(7).Values = _
"='" & Me.txtPartNum.Value & "'!PerCoTolA"

I have some hints for working with charts in VBA on my web site:
http://www.geocities.com/jonpeltier/...kChartVBA.html

- Jon
-------
Jon Peltier, Microsoft Excel MVP
http://www.geocities.com/jonpeltier/Excel/index.html
_______

arobustus wrote:
I really hope that someone can help me with this, because it is driving me crazy.
The code below is part of a routine which adds a worksheet based on a form, then creates a chart for that newly created
worksheet. There are 4 if/then statements similar to the one shown, so that uses can set up to four lines on the chart,
depending on whether or not they have entered anything in a given textbox. (BTW there are 12 text boxes in groups of 3
per each of 4 frames.)
The ".SeriesCollection.NewSeries" statements are from the original recorded macro.

When it gets to the line:
..SeriesCollection(7).Values = "=" & Me.txtPartNum.Value & "!PerCoTolA"
it sometimes (!!!) generates the error:

Run-time error '1004':
Unable to set the Values property of the Series class

"Me.txtBPA" is one of the controls on the form.
"PerCoTolA" is a named range on the newly created sheet. As one creates new sheets, they all have the smae named ranges
and cells.

The really odd thing is that "sometimes", as if the code is basically OK but somewhat unstable, or something like that.
If it would just occur all the time, I could understand. So far I have been unable to figure out what, if any, squence
of actions on my part causes the error to be generated "this" time rather than "that".

I thought it might be better if I created a variable of type "SeriesCollection" & set it to each one in turn, then
manipulated that, but I was unable to come up with a way to do it which did not generate another error.

Charts.Add
Set chNew = ActiveChart
With chNew
.ChartType = xlLineMarkers

'Add Chart Series for 25%, 50%, 75% lines
.SeriesCollection.NewSeries
.SeriesCollection.NewSeries
.SeriesCollection.NewSeries
.SeriesCollection.NewSeries
.SeriesCollection.NewSeries
.SeriesCollection.NewSeries

'Add Chart Series for measured values as needed

If Me.txtBPA.Value < "" Then
.SeriesCollection.NewSeries
'***Error Generated on next line:**
.SeriesCollection(7).Values = "=" & Me.txtPartNum.Value & "!PerCoTolA"
.SeriesCollection(7).Name = "=" & Me.txtPartNum.Value & "!BP_A"
End If

I would be very grateful for any help with this.
-plh

I keep hitting "Esc" -- but I'm still here!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem with setting values for SeriesCollection

On Mon, 1 Sep 2003 20:56:30 -0700, "Greg Wilson" kindly wrote:
[snip]

My understanding is that named ranges are the property of
the workbook (as opposed to worksheet) object. Therefore,
you can only have ONE named range with the same name in
the same project. It seems implied that you are trying to
create multiple named ranges with the same name. This may
be causing a glitch. Try removing this part of your code
experimentally.


Thanks for pointing that out. I am copying a sheet called "Blank", using the .Copy After command, resulting in duplicate
range names from sheet to sheet. What I guess I can do is incorporate the new sheet name into the range name, or some
other unique identifier, so that all range names will be unique. Is there any limit on the total number number of range
names one can have?

Also, try changing the range name to
something that does not have a number included (i.e. "XXX"
instead of "PerCoTo1A"). It seems to me that in the past


It is actually "PerCoTolA" but IAC thanks for the tip.
[snip]


Simplified code used for test:
Private Sub UserForm_Click()
Dim chNew As ChartObject, i As Integer, S As Series
Set chNew = ActiveSheet.ChartObjects.Add(50, 50, 200, 200)
With chNew.Chart
.ChartType = xlLineMarkers
For i = 1 To 6
.SeriesCollection.NewSeries
Next
If txbBPA.Value < "" Then
Set S = .SeriesCollection.NewSeries
S.Values = Range("PerCoTo1A")
S.Name = Range("BP_A")
End If
End With
End Sub


Regards,
Greg


-----Original Message-----
Your code worked for me. Is txtPartNum always a valid

sheet name? You
might try enclosing it in single quotes:

..SeriesCollection(7).Values = _
"='" & Me.txtPartNum.Value & "'!PerCoTolA"

I have some hints for working with charts in VBA on my

web site:
http://www.geocities.com/jonpeltier/...artsHowTo/Quic

kChartVBA.html

- Jon
-------
Jon Peltier, Microsoft Excel MVP
http://www.geocities.com/jonpeltier/Excel/index.html
_______

arobustus wrote:
I really hope that someone can help me with this,

because it is driving me crazy.
The code below is part of a routine which adds a

worksheet based on a form, then creates a chart for that
newly created
worksheet. There are 4 if/then statements similar to

the one shown, so that uses can set up to four lines on
the chart,
depending on whether or not they have entered anything

in a given textbox. (BTW there are 12 text boxes in groups
of 3
per each of 4 frames.)
The ".SeriesCollection.NewSeries" statements are from

the original recorded macro.

When it gets to the line:
..SeriesCollection(7).Values = "=" &

Me.txtPartNum.Value & "!PerCoTolA"
it sometimes (!!!) generates the error:

Run-time error '1004':
Unable to set the Values property of the Series class

"Me.txtBPA" is one of the controls on the form.
"PerCoTolA" is a named range on the newly created

sheet. As one creates new sheets, they all have the smae
named ranges
and cells.

The really odd thing is that "sometimes", as if the

code is basically OK but somewhat unstable, or something
like that.
If it would just occur all the time, I could

understand. So far I have been unable to figure out what,
if any, squence
of actions on my part causes the error to be

generated "this" time rather than "that".

I thought it might be better if I created a variable of

type "SeriesCollection" & set it to each one in turn, then
manipulated that, but I was unable to come up with a

way to do it which did not generate another error.

Charts.Add
Set chNew = ActiveChart
With chNew
.ChartType = xlLineMarkers

'Add Chart Series for 25%, 50%, 75% lines
.SeriesCollection.NewSeries
.SeriesCollection.NewSeries
.SeriesCollection.NewSeries
.SeriesCollection.NewSeries
.SeriesCollection.NewSeries
.SeriesCollection.NewSeries

'Add Chart Series for measured values as needed

If Me.txtBPA.Value < "" Then
.SeriesCollection.NewSeries
'***Error Generated on next line:**
.SeriesCollection(7).Values = "=" &

Me.txtPartNum.Value & "!PerCoTolA"
.SeriesCollection(7).Name = "=" &

Me.txtPartNum.Value & "!BP_A"
End If

I would be very grateful for any help with this.
-plh

I keep hitting "Esc" -- but I'm still here!


.


I keep hitting "Esc" -- but I'm still here!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SeriesCollection question EAB1977 Charts and Charting in Excel 2 December 22nd 08 02:29 PM
Excel setting problem Rajula Excel Discussion (Misc queries) 4 January 26th 07 09:29 AM
.SeriesCollection(2).Name and .Deselect Peter Sie Charts and Charting in Excel 2 July 3rd 06 03:10 AM
SeriesCollection Values Property Oddity Greg Wilson Charts and Charting in Excel 4 December 3rd 05 04:26 AM
Dynamically Change Row Count Using SeriesCollection(n).Values [email protected] Charts and Charting in Excel 0 August 15th 05 03:56 PM


All times are GMT +1. The time now is 01:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"