Chart series

A

Arne Hegefors

Hello! I have previously posted questions in this field but I have never
gotten an answer. I really really need help with this. I have never
programmed before and now I am supposed to do this VBA application for Excel.
What I want to do is simple enough but I have trouble implementing it and
since and really do not know anything about programming I do not know what is
wrong. The problem is that I am supposed to replace the existing series for a
chart with new series. I have the new series but when applying them to a new
chart it does not work if I have not manually erased the old chart series.
This does not seem like an obstacle but this code have to work for other
applications. I try to change the series in a loop. Code:

Do While k < (UBound(rng))
If Not IsEmpty(rng(k)) Then
ActiveChart.SeriesCollection(k).Values =
Sheets(varWorksheetInfoArray(0)).Range(rng(k).Offset(i, 0).Address & ":" &
rng(k).Offset(j, 0).Address)
Else: End If
k = k + 1
Loop
The find function returns the correct range so that is not a problem. The
problem is that if the chart already has a series the new data does not apply
to the chart. I have tried referring to the number instead of the name of the
series but with no success. Is there anything that you should do with the
chart (this is the first time I am using xl/vba)? Should you try to delete
the series or something. Please if you know anything about this help me out.
If you see that the code is correct then let me know. I know I have posted
questions about this before but I really must get this to work and I have not
gotten a proper answer. I have never programmed before and now I am stuck
until midnight every day since I have to do this outside of my other things.
I know that it just a line or something that is missing but I have no clue
where/what or how to figure it out. Please I am begging all you out there if
you know anything about this help me out. I have vistited e.g. the Metha
Consulting page where there are tips for dynamically chart making but that
does not apply here. Please again any help is truly appreciated!
 

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