ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unable to set the Chart type to XY Plotter (https://www.excelbanter.com/excel-programming/284567-unable-set-chart-type-xy-plotter.html)

Amit Kale

Unable to set the Chart type to XY Plotter
 
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:P" & 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

MattShoreson[_7_]

Unable to set the Chart type to XY Plotter
 

try...

.ChartType = xlXYScatte

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements

Jon Peltier[_4_]

Unable to set the Chart type to XY Plotter
 
Amit -

You need to use the correct long value for xlXYScatter, which is -4169.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
http://www.geocities.com/jonpeltier/Excel/index.html
_______

Amit Kale wrote:

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:P" & 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




All times are GMT +1. The time now is 05:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com