virginiadopa.blogg.se

How do i add a series to a scatter chart in excel
How do i add a series to a scatter chart in excel







how do i add a series to a scatter chart in excel
  1. #How do i add a series to a scatter chart in excel how to#
  2. #How do i add a series to a scatter chart in excel code#

Whenever adding a chart via VBA it's a good practice to first delete any series which got auto-added. If you insert a chart sheet or chartobject while there's data selected on a worksheet, the chart will auto-plot the selected data. Axes(xlValue, xlPrimary).AxisTitle.Text = "Power (kW)" Axes(xlValue, xlPrimary).HasTitle = True Axes(xlCategory, xlPrimary).AxisTitle.Text = "Time (h)" Axes(xlCategory, xlPrimary).HasTitle = True SetElement (msoElementChartTitleAboveChart) ' If there is a previous chart, delete it

how do i add a series to a scatter chart in excel

Any ideas on whats causing this? Sub CreatingChartOnChartSheet()

#How do i add a series to a scatter chart in excel code#

Continuing to rerun my code repeats the cycle of good plot -> bad plot -> good plot. Then, when I run the code a third time, I get the correct plot once again. However, when I rerun the code with a "Power Chart" present, I get 3 additional series showing up, two with blank data and one with only y values, corresponding to the last column in my worksheet. when there is no "Power Chart" present), it plots the data correctly. When I run the code shown below for the first time (i.e. change the secondary x-axis max range to 1.I am trying to create an xy scatter plot on its own worksheet using VBA. remove the major and minor tick marks from the secondary (top) x-axis creates Axis objects for the secondary axesĮxcel.Axis YAxis2 = (Excel.Axis)sChartCPU.Axes(, ) Įxcel.Axis XAxis2 = (Excel.Axis)sChartCPU.Axes(, ) instead of setting the Formula, I set the series values To do this, right click on the orange dots (slope series) and select Change series chart type. line.Formula = "=SERIES(Summ!$D$54,Summ!$C$55:$C$56,Summ!$D$55:$D$56)" Change the slope series to Scatter with straight line type of chart.

#How do i add a series to a scatter chart in excel how to#

Here's the solution I found to the OP's question of how to remove the secondary axes: Excel.SeriesCollection threshold = sChartCPU.sseriesCollection() If I comment out the line.ChartType, then the axis is correct but I only get one threshold data point ? I don't understand why. I don't know how to remove the 2 additional axis that appear in chart

how do i add a series to a scatter chart in excel

The values I have in cells D54 - threshold C55 = 0 When the threshold line is created I have the following summar圜hartCPU.SetSourceData(summaryMemThreshold, Type.Missing) - things breakĮxcel.SeriesCollection threshold = sChartCPU.sseriesCollection() Įxcel.Series line = threshold.NewSeries() I don't know how to add the threshold line to the graph with the existing graph being displayed YSChartCPUAxis.MaximumScaleIsAuto = true Įxcel.Series sCPUSeries = sChartCPU.SeriesCollection(1) SChartCPU.ChartWizard(Source: cpuChartRange, Gallery:, Format: 2, HasLegend: true)

how do i add a series to a scatter chart in excel

SChartCPU.SetSourceData(cpuChartRange, Missing.Value) Is this chart already created in the excel file, and you want to modify the chart in the excel file? yes the chart is already in a Excel file.Įxcel.ChartObject sCPUChartObjects sCPUChart = sDBSheet.ChartObjects(Type.Missing) How are you creating the chart? - see code below. I am trying to add an additional data series to the chart this shows CPU threshold, I can get the range and create the graph with out the threshold on it, but I don't know how to add the threshold value to the chart.ĭo I need to create another chart object? can I use the existing and just add teh new range in?









How do i add a series to a scatter chart in excel