View Full Version : problem with Reading and plotting data in VBA - excel application

10-23-2008, 01:03 AM
Hello everyone,

I have a excel sheet of 5 columns, each with 5 rows. First,I read some selected columns from the sheet. then perform an arithmetic operation on all elements of the selected columns. then draw a chart with the modified columns.

My code is as follows(please see the comments to know what i am doing)

Dim y(1 To 5) As String 'declaring a string array

y(1) = "=sheet1!R1C1:R5C1" 'Reading columns
y(2) = "=sheet1!R1C2:R5C2"
y(3) = "=sheet1!R1C3:R5C3"
y(4) = "=sheet1!R1C4:R5C4"
y(5) = "=sheet1!R1C5:R5C5"

dim NewY(1 to 5) as double
For i = 1 To 5
NewY(i) = Sheets("sheet1").Cells(i , 3) + 2.02 'Adding 2.02 to all elements of column3

Next i

ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SeriesCollection(1).XValues =y(1) ' X-axis is column1
ActiveChart.SeriesCollection(1).Values = xxxxxxxx

Can any one help me, What should I write here in place of xxxxxxxx to make a plot between Column 1 of my sheet to the modified values of column 3?

thanks in advance!