Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Variable Range/chart

I have a program that will generate a chart using a variable range up to a
length of 17 cells. If the length is 18 or greater, I get a "Run-time error
'1004': Unable to set the values property of the series class."

My goal is to be able to generate a chart for varying cell lengths (like a
range of 150 to 200 cells).

What is the best way to do so, and why does the program as written only work
for
sstop < 17?

Sub dynamicrangetest()

Dim vrange As Variant
Dim irange As Variant

Dim cht As chart
Dim senewseries As Series

sstart = 4
vcol = 3
icol = 4
sstop = 204

irange = Range(Cells(sstart, icol), Cells(sstop, icol)).Value
vrange = Range(Cells(sstart, vcol), Cells(sstop, vcol)).Value
Set cht = Charts.Add

With cht
.ChartType = xlLine
Set senewseries = .SeriesCollection.NewSeries
senewseries.Values = irange
senewseries.xvalues = vrange

End With

End Sub

Thank you in advance for any suggestions.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Variable Range/chart

create one with 17 cells.

then manually go into the chart and select the series. Look up in the
formula bar. I suspect the formula will be approaching the string length
limit for a formula.

You will probably need to put your array in a defined name (equivalent to
Insert=Name=Define) and then assign that defined name as the source for
your series.

A defined name will work as long as you don't try to look at it manually (it
can hold a large array).

--
Regards,
Tom Ogilvy


"ballyb" wrote:

I have a program that will generate a chart using a variable range up to a
length of 17 cells. If the length is 18 or greater, I get a "Run-time error
'1004': Unable to set the values property of the series class."

My goal is to be able to generate a chart for varying cell lengths (like a
range of 150 to 200 cells).

What is the best way to do so, and why does the program as written only work
for
sstop < 17?

Sub dynamicrangetest()

Dim vrange As Variant
Dim irange As Variant

Dim cht As chart
Dim senewseries As Series

sstart = 4
vcol = 3
icol = 4
sstop = 204

irange = Range(Cells(sstart, icol), Cells(sstop, icol)).Value
vrange = Range(Cells(sstart, vcol), Cells(sstop, vcol)).Value
Set cht = Charts.Add

With cht
.ChartType = xlLine
Set senewseries = .SeriesCollection.NewSeries
senewseries.Values = irange
senewseries.xvalues = vrange

End With

End Sub

Thank you in advance for any suggestions.

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
Variable Range to be used in a chart Jeff Excel Worksheet Functions 1 February 9th 07 03:22 AM
Variable range chart Nikki Excel Discussion (Misc queries) 4 October 20th 06 08:07 PM
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM
Excel VBA-Change chart range to variable waveracerr[_10_] Excel Programming 1 February 11th 04 04:39 PM
Problem trying to us a range variable as an array variable TBA[_2_] Excel Programming 4 September 27th 03 02:56 PM


All times are GMT +1. The time now is 11:30 PM.

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

About Us

"It's about Microsoft Excel"