Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Looping Through Data to do plots

  Asked By: Sienna    Date: Feb 17    Category: MS Office    Views: 858
  

I need to create multiple plots from a spreadsheet. Here is what I have

I have a variable, say numseries = K. I have data in columns in the first
K+1 columns and also in columns K+2 to 2K+1 in a spreadsheet. I have N rows.
For ease of writing, I will call them cells(1,1) to Cells(100, 2K+1)

I want to LOOP through so that I create scatter plot for Range(Cells(1,1),
Cells(100,1)) and Range(Cells(1,j+1), Cells(100,j+1)) AS WELL AS
Range(Cells(1,1), Cells(100,1)) and Range(Cells(2,j+1+K),
Cells(100,j+1+K)) in a chart.

I want to loop this for j = 1 to K

I was doing something like:

For i = 1 to K
charts.add
activechart.ChartType = xlXYScatter

ActiveChart.Series.Collection.NewSeries

Activechart.series.collection(1).Xvalues=Range(Cells(1,1), Cells(100,1))
Activechart.series.collection(1).Values=Range(Cells(1,j+1), Cells(100,j+1))


Activechart.series.collection(2).Xvalues=Range(Cells(1,1), Cells(100,1))
Activechart.series.collection(2).Values=Range(Cells(1,j+1+K),
Cells(100,j+1+K))

SOME OTHER CHART STATEMENTS ARE ERASED
Next i

For each of the chart it only plots the values for j=K and not for the
individual series that I thought it should do.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Emma Campbell     Answered On: Feb 17

I haven't thoroughly examined your code (a little complex),
but maybe this brute force approach will help.

Instead of posting your results directly into the chart  object,
just post them in a vacant column. If you expect 500 data  points,
just have your code put them in 500 rows. Then, manually select
the range and create  the chart. If nothing else, you may uncover
a logic error during your attempt to populate the column with the
500 data points.

 
Didn't find what you were looking for? Find more on Looping Through Data to do plots Or get search suggestion and latest updates.




Tagged: