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: 1
Default Problem using arrays in Excel Charts from VBA


Found several similar threads but nothing that seems to address thi
problem.

If I copy an Excel range into a variant, varArray and then use
.SeriesCollection.Values = varArray I get Runtime 1004 error "Unable t
set the Values property of the Series class". I've tried first copyin
the 2D variant into a 1D double or variant to get a 1D array but sam
message results.

However if I just populate varArray locally with random numbers i
works okay. Also I've found that what I originally wanted to do work
up to 14 elements in varArray but fails when I increase the size t
15?

Examples of what work and what doesn't below - any guidance muc
appreciated. (I know I can just use Ranges in the chart but I woul
prefer not to have to.)

Fails:

varT = Range("T").Offset(1, 0).Resize(, 1).Value
ReDim dT(1 To 15)
ReDim dX(1 To 15)
For i = 1 To 15
dT(i) = varT(i, 1)
dX(i) = i
Next i

varT = dT
varX = dX

Set TheChart = Charts.Add

With TheChart

.Name = sChart
.ChartType = xlXYScatterLines

Set TheSeries = .SeriesCollection.NewSeries
TheSeries.Values = varT
TheSeries.XValues = varX

.....

Works:

varT = Range("T").Offset(1, 0).Resize(, 1).Value
ReDim dT(1 To 14)
ReDim dX(1 To 14)
For i = 1 To 14
dT(i) = varT(i, 1)
dX(i) = i
Next i

varT = dT
varX = dX

Set TheChart = Charts.Add

With TheChart

.Name = sChart
.ChartType = xlXYScatterLines

Set TheSeries = .SeriesCollection.NewSeries
TheSeries.Values = varT
TheSeries.XValues = varX

.....

Works:

ReDim dT(1 To 50)
ReDim dX(1 To 50)
For i = 1 To 50
dT(i) = CDbl(i/2)
dX(i) = i
Next i

varT = dT
varX = dX

Set TheChart = Charts.Add

With TheChart

.Name = sChart
.ChartType = xlXYScatterLines

Set TheSeries = .SeriesCollection.NewSeries
TheSeries.Values = varT
TheSeries.XValues = varX

....

--
Chris_Hawkin
-----------------------------------------------------------------------
Chris_Hawkins's Profile: http://www.excelforum.com/member.php...fo&userid=2692
View this thread: http://www.excelforum.com/showthread.php?threadid=40145

 
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
Excel Charts - Text Box Problem tpearo Charts and Charting in Excel 1 June 21st 06 04:14 PM
Problem with SUMPRODUCT and Arrays [email protected] Excel Worksheet Functions 2 January 13th 06 09:55 PM
Making charts from arrays in VBA Ali Baba Charts and Charting in Excel 3 August 30th 05 04:49 PM
VBA (arrays problem) Ali Baba Excel Programming 6 August 23rd 05 01:44 AM
Elusive Problem with Arrays [email protected] Excel Programming 3 April 29th 05 12:50 AM


All times are GMT +1. The time now is 01:23 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"