Chart making

S

Sally Mae

I am making a report that is get its data from workbook. Now the report is
already made i.e. the charts and tables ar done but the input data is old.
Therefore I have a macro that searches the new info and (tries to) update the
charts and tables. I have a problem though with getting the charts to work.
The code works like this:
1) I specifiy certain headings to search for and stores the address of the
these cells. and then use these cells as point of reference to get the
indata. Code:

If index = 0 Then
varWorksheetInfoArray(0) = "Data"
varWorksheetInfoArray(1) = "Value"
varWorksheetInfoArray(2) = "Exchange rate"
varWorksheetInfoArray(3) = "Inflation"
end if
Call chartMaker1(varWorksheetInfoArray)

I then call a sub that is to replace to old values in the charts with the
new ones.

Private Sub chartMaker1(ByRef varWorksheetInfoArray() As Variant)
Dim i, j As Integer
Dim rng1, rng2, rng3, rng4 As Range

In here I look for the addresses that I need (all these things work..)
If IsEmpty(varWorksheetInfoArray(0)) = False Then
Set rng1 =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(varWorksheetInfoArray(1),
LookIn:=xlValues)
etc..

I then iterate my way through the data to get the correct range (that also
works). Neverthe i and j that are coming they work and specifies the
addresses that sets the range.

Now here comes my problem. I try to get new info to the charts by writing:

Sheets("Rapport").Select
ActiveSheet.ChartObjects("Diagram 2").Activate
With ActiveChart
.SeriesCollection(1).Values = Range(rng2.Offset(i, 0).Address & ":"
& rng2.Offset(j, 0).Address)
.SeriesCollection(2).Values = Range(rng3.Offset(i, 0).Address & ":"
& rng3.Offset(j, 0).Address)
.SeriesCollection(1).XValues =
Sheets(varWorksheetInfoArray(0)).Range(rng1.Offset(i, 0).Address,
rng1.Offset(j, 0).Address)
End With

and it just does not work. All addresses etc. ar correct, it is just the
syntax how to get the new info to the charts that is not working..Please I
would be very thankful if anyone oculd help me!! Thanks!
 

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

Similar Threads

Looping Range 0
Loop and name 3
Checking contents of arrays 1
Type mixture error 2
Update charts 0
Syntax error.. 1
Replace/substitute 0
Series 3

Top