VBA code NewSeries works only once

J

JeroenM

I'm using VBA code in Access to export a query to Excel. After that I want to
create a graph of the exported data. I use the piece of VBA code below to
make this graph:

With .SeriesCollection.NewSeries
.XValues = Range(xlAppForm.Worksheets("BU1").Cells(16, 3),
lAppForm.Worksheets("BU1").Cells(27, 3))
.Values = Range(xlAppForm.Worksheets("BU1").Cells(16, 16 + icolomn *
Sprong), xlAppForm.Worksheets("BU1").Cells(27, 16 + icolomn * Sprong))
.Name = xlAppForm.ActiveSheet.Cells(16, 2 + icolomn * Sprong)
End With

This piece of VBA code works fine. The only problem is it works only once. I
have to restart Access and after that the graphs are created nicely, but
after a second time running the VBA code it doesn't add a serie to a graph. I
have to restart Access again and then it works again for 1 time.

When I replace .XValues ... and .Values ... with the following code it works
every time (so also without restarting Access).
'.XValues = Array(1, 2)
'.Values = Array(2, 3)

What should I do to solve this problem.

Thanks in advance, JeroenM.
 

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