I am trying to plot data on both the X & Y. Right now I have the data being plotted on the Y with the X being the ctr/index. I want the X to have data on it as well. Here is my C# code.
Code:Excel.ChartObjects charts = (Excel.ChartObjects)excelWs.ChartObjects(Type.Missing); Excel.ChartObject chartObj = charts.Add(5, 45, 400, 300); Excel.Chart chart = chartObj.Chart; Excel.Range chartRange = excelWs.get_Range("C32", "C40"); chart.SetSourceData(chartRange, Type.Missing); chart.ChartType = Excel.XlChartType.xlXYScatter; chart.Legend.Delete(); Excel.SeriesCollection seriesCollection = (Excel.SeriesCollection)chart.SeriesCollection(Type.Missing); Excel.Series series = seriesCollection.Item(seriesCollection.Count);
I can get this to work in a xls macro. Here is the code for what I want in vba.
Thanks in advance.Code:Charts.Add ActiveChart.ChartType = xlXYScatter ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A1:F4"), PlotBy _ :=xlRows ActiveChart.SeriesCollection(2).Delete ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R2C5:R4C5" ActiveChart.SeriesCollection(1).Values = "=Sheet1!R2C2:R4C2" ActiveChart.SeriesCollection(1).Name = "=""Test"""




Reply With Quote