Problem with Second value Y Axis

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
 
J

Jon Peltier

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top