Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the number in the AddChart2 VBA macro represent?

I've use my Excel 2013 to record a macro in inserting a chart, a column-clustered chart in my case. In the view code option, it shows me a line of code as below:

ActiveSheet.Shapes.Addchart2(286,xl3DColumnClustered).Select

Please help me as I cannot understand what does the number 286 represent. I know the syntax of Addchart2 is:

expression.AddChart2(Style,XlChartType,Left,Top,Width,Height,NewLayout)

If I change the "286" to "285", the chart appears with a blue background. An error comes out if the number is 100.

Can anyone kindly tell me what does the number represent?

like image 354
OneBaseNotch Avatar asked Jan 11 '15 16:01

OneBaseNotch


People also ask

How do you create a chart in VBA?

Step 1: Start Sub Procedure. Step 2: Define the variable as Chart. Step 3: Since the chart is an object variable, we need to Set it. The above code will add a new sheet as a chart sheet, not as a worksheet.


1 Answers

One can also provide only the ChartType and the application will use the default style.

Set oShp = ActiveSheet.Shapes.AddChart2(XlChartType:=xl3DColumnClustered)
oShp.Chart.SetSourceData Source:=RngDta

This picture shows the default ChartStyle for all ChartTypes (excluding StockHLC and StockVOHLC)

enter image description here

like image 70
EEM Avatar answered Oct 05 '22 23:10

EEM