VBA chart problem

E

es330td

I have a Excel app that is supposed to include a chart. The data
consists of three columns; a month number, a cumulative projected
budget and cumulative actual expenditures

1 2000 1982
2 4000 4023
3 7000 6995
4 8000
5 11000
6 11500

I am trying to make a chart with two series; one will be the projected
budget, the other the actual expenditures. The actual line should
track the projected line for whatever actual data exists then the
projected line should continue through its data points.

This is the code I wrote trying to generate this chart:

Worksheets("PR Cashflow").Activate
Set crt = ActiveSheet.ChartObjects.Add(475, 40, 520, 300)
crt.Chart.ChartType = xlLineMarkersStacked
crt.Chart.PlotBy = xlColumns

With crt.Chart.SeriesCollection.NewSeries
.Values = ActiveSheet.range("AB5:AB13")
.XValues = ActiveSheet.range("AA5:AA13")
End With

With crt.Chart.SeriesCollection.NewSeries
.Values = ActiveSheet.range("AC5:AC8")
.XValues = ActiveSheet.range("AA5:AA13")
End With

Here is the problem I am having: when it adds the second series to the
chart it appears as though the y axis values are getting added so
instead of the first data points being 1,2000 and 1,1982 it looks like
they are 1,2000 and 1,3982

What am I missing here?
 
E

es330td

I have a Excel app that is supposed to include a chart. The data
consists of three columns; a month number, a cumulative projected
budget and cumulative actual expenditures

1 2000 1982
2 4000 4023
3 7000 6995
4 8000
5 11000
6 11500

I am trying to make a chart with two series; one will be the projected
budget, the other the actual expenditures. The actual line should
track the projected line for whatever actual data exists then the
projected line should continue through its data points.

This is the code I wrote trying to generate this chart:

Worksheets("PR Cashflow").Activate
Set crt = ActiveSheet.ChartObjects.Add(475, 40, 520, 300)
crt.Chart.ChartType = xlLineMarkersStacked
crt.Chart.PlotBy = xlColumns

With crt.Chart.SeriesCollection.NewSeries
.Values = ActiveSheet.range("AB5:AB13")
.XValues = ActiveSheet.range("AA5:AA13")
End With

With crt.Chart.SeriesCollection.NewSeries
.Values = ActiveSheet.range("AC5:AC8")
.XValues = ActiveSheet.range("AA5:AA13")
End With

Here is the problem I am having: when it adds the second series to the
chart it appears as though the y axis values are getting added so
instead of the first data points being 1,2000 and 1,1982 it looks like
they are 1,2000 and 1,3982

What am I missing here?

I was missing this: crt.Chart.ChartType = xlLineMarkersStacked

It should have been xlLineMarkers

Doh!
 

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