LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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!


 
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 08:11 PM.

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"