Using other than Range as SetSourceData method argument

C

CKa

Hi.

I have been trying to find another way to populate a chart in some VBA code
than using a range as a argument for the SetSourceData method of the Chart
object.

I get a lot of external data (from a database) into an array of 2 dimensions
(x and y). Is it possible to use this array to as a datasource without first
having to populate some cells with the array and then use these cells as a
Range property for populating a chart?

Thanks in advance,

CKa.
 
J

Jon Peltier

It takes a little more work. In VBA, set up the X and Y value arrays for
each series. Then add the series one by one:

Dim Srs as Series
With ActiveChart.SeriesCollection
Set Srs = .NewSeries
With Srs
.Values = Yarray
.XValues = Xarray
End With
End With

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
 
C

CKa

Thank you for your help.

Your VBA code example did exactly what I was looking for.

Best regards,

CKa.
 

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