VBA code to draw chart doesn't work in Excel 2003 (created in 2007)

gerbenv

New Member
Joined
Jul 15, 2010
Messages
1
I have a VBA macro in excel created in Excel 2007 that works fine in Excel 2007. However, when running in Excel 2003 it refuses to draw the chart and returns an error on the first line of the code below.

The macro runs fine up to this part about the graph:
Code:
Sheets("grafiek").Shapes.AddChart.Select
    ActiveChart.ChartType = xlLine
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection(1).Values = Sheets("grafiek").Range(Cells(2, 2), Cells(Eind - Begin + 2, 2))
    ActiveChart.SeriesCollection(1).XValues = Sheets("grafiek").Range(Cells(2, 1), Cells(Eind - Begin + 2, 1))

Goal of this code:
This part of the macro tries to create a line chart on the worksheet "grafiek" with two lines: one with the values of column B and one with the values of column C. The values of column A needs to be on the x-axes.

However, the length of the columns varies, therefore the last rownumber of the range that need to be plotted is defined by the sum of the integers "Eind - Begin + 2". (Those "eind" and "begin" are defined earlier in the macro.)

If anyone knows what is non-2003 compatible or has another suggestion how to reach this goal, please let me know!
Thanks in advance.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top