[EXCEL] Chart creation: X and Y series?
Hi all --
This seems like a really simple task, but I've looked all over and I can't find anything about it. I'm creating a series of charts in a number of Excel sheets, working fine so far. I then need to make three series. The first using X values from A13:A3000 and Y Values from B13:B3000. I can get the X Values set fine. But for the life of me I don't know how to set Y Values. Code below.
Code:
Dim shtData As Worksheet
Set shtData = oExcel.Sheets("Layer " & N)
shtData.Activate
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).Name = "Raw"
ActiveChart.SeriesCollection(1).XValues = _
Worksheets("Layer " & N).Range("A13:A3000")
ActiveChart.SeriesCollection(1).Values = _
Worksheets("Layer " & N).Range("B13:B3000")
ActiveChart.SeriesCollection(2).Name = "Trans"
ActiveChart.SeriesCollection(2).XValues = _
Worksheets("Layer " & N).Range("A13:A3000")
ActiveChart.SeriesCollection(2).Values = _
Worksheets("Layer " & N).Range("D13:D3000")
ActiveChart.SeriesCollection(3).Name = "Cos"
ActiveChart.SeriesCollection(3).XValues = _
Worksheets("Layer " & N).Range("A13:A3000")
ActiveChart.SeriesCollection(3).Values = _
Worksheets("Layer " & N).Range("J13:J3000")
Any help is immensely appreciated. I've been working at this for days on and off. And if anyone can tell me how to relocate the chart within the sheet (eg by pixels, etc) that would also be great.
Re: [EXCEL] Chart creation: X and Y series?
Quote:
This seems like a really simple task
trust me, everytime i worked with diagrams in excel programatically it was NOT an easy task ;)
however, i tried your code and it worked perfectly well. when i enter lets say 1 in A13 and 5 in B13 a point is plotted in the diagram at coordinates X=1, y=5, so what did you expect?