A
Amit Kale
I am trying to set the chart types to XYScatter through code. I am
using the Createobject(Excel.App...) instead of referencing the excel
object.
However, i end up setting the chart type to any of the XY Scatter (XY
Scatt with data points connected, smoothed lines, etc) but cannot
create the simple XYScatter(just points).
The chartType for XYScatter starts from 71 thru 74 (70 is the pie
chart and 75 is area chart).
Has any bdy come across such problem, any suggestions??
Thanks
Heres the code:
Set xlChart = xlChartSheet.chartobjects.Add(360, 5, 350, 250).Chart
With xlChart
.ChartType = 72
.SeriesCollection.Add Source:=xlWS.Range("A4:A" & lastRow & ", " &
xlWS.Cells(4, colCount + 1).Address & ":" & Left(xlWS.Cells(4,
colCount + 1).Address, 3) & lastRow), RowCol:=2
.SeriesCollection(1).XValues = xlWS.Range("P4" & lastRow)
.SeriesCollection(1).Values = xlWS.Range("E4:E" & lastRow)
.SeriesCollection(1).TrendLines.Add
.HasTitle = True
.ChartTitle.Caption = "Gas vs Power Price"
.HasLegend = False
.PlotArea.Height = 280
.PlotArea.Width = 490
End With
using the Createobject(Excel.App...) instead of referencing the excel
object.
However, i end up setting the chart type to any of the XY Scatter (XY
Scatt with data points connected, smoothed lines, etc) but cannot
create the simple XYScatter(just points).
The chartType for XYScatter starts from 71 thru 74 (70 is the pie
chart and 75 is area chart).
Has any bdy come across such problem, any suggestions??
Thanks
Heres the code:
Set xlChart = xlChartSheet.chartobjects.Add(360, 5, 350, 250).Chart
With xlChart
.ChartType = 72
.SeriesCollection.Add Source:=xlWS.Range("A4:A" & lastRow & ", " &
xlWS.Cells(4, colCount + 1).Address & ":" & Left(xlWS.Cells(4,
colCount + 1).Address, 3) & lastRow), RowCol:=2
.SeriesCollection(1).XValues = xlWS.Range("P4" & lastRow)
.SeriesCollection(1).Values = xlWS.Range("E4:E" & lastRow)
.SeriesCollection(1).TrendLines.Add
.HasTitle = True
.ChartTitle.Caption = "Gas vs Power Price"
.HasLegend = False
.PlotArea.Height = 280
.PlotArea.Width = 490
End With