Charts

B

Bob

Hi Everyone:

In excel, I would like to plot an array Y versus an array X as a scattered
plot. When looking at the chart methods, I could only see how to plot a
range, and not two arrays. For example I know to plot a range, I have to
use: ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("C10:D17").

Can someone please show me how to plot Y vs. X without writing the data to
the spreadsheet and then reading the range.

Thanks;

Bob
 
A

Andy Pope

Hi,

You can not use the SetSourceData method as it expects a range reference.
Instead you can you the NewSeries method.

With ActiveChart
With .SeriesCollection.NewSeries
.Values = Array(1, 2, 3, 4, 5)
.XValues = Array(2, 4, 2, 4, 2)
End With
End With

Not that the series formula has a limit to it's length of approx 1024
characters.

Cheers
Andy
 
B

Bob

Thanks Andy. That is exactly what I wanted to do, but did not know how. I
did not know about the NewSeries method. Thanks.

Bob
 

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