Problem with Second value Y Axis

  • Thread starter Thread starter rishi
  • Start date Start date
R

rishi

HI,
I create chart using VBA.
I use chart type is XlLine. but it want show the second
value of Y axis. My requirement is show data and Axis
Title.

My code is
Set objChart = objWorkSheet.ChartObjects.Add(50, 20,
500, 300).Chart

With objChart.SeriesCollection.NewSeries
.Name = "Reduction Goal"
.Values = objWorkSheet.Range("F2:F10")
.XValues = objWorkSheet.Range("B2:B10")
End With

With objChart.SeriesCollection.NewSeries
.Name = " "
.Values = objWorkSheet.Range("E2:E10")
.XValues = objWorkSheet.Range("B2:B10")
End With

With objChart.SeriesCollection.NewSeries
.Name = objWorkSheet.Range("C1")
.Values = objWorkSheet.Range("C2:C10")
.XValues = objWorkSheet.Range("B2:B10")
End With

With objChart.SeriesCollection.NewSeries
.Name = objWorkSheet.Range("D1")
.Values = objWorkSheet.Range("D2:D10")
.XValues = objWorkSheet.Range("B2:B10")
End With

objChart.HasTitle = True
objChart.ChartTitle.Text = txtBuilding.Value & "
Reduction Prograss"
objChart.Legend.Position = xlLegendPositionBottom

With objChart.Axes(xlCategory, xlPrimary)
.HasTitle = True
.AxisTitle.Text = ""
End With
With objChart.Axes(xlValue, xlPrimary)
.HasTitle = True
.AxisTitle.Text = "(1 YR CUMULATIVE)"
End With
objChart.Type = xlLine
 
To get a secondary axis, at least one series has to be plotted on that
axis. In one of the With NewSeries you need to insert .AxisGroup =
xlSecondary

- Jon
 
Back
Top