create graphic autmatically with VB

  • Thread starter Thread starter Elve
  • Start date Start date
E

Elve

Hello

I need your help for create graphics.
I create graphics from a page with many source data

For example:

avril mai juin
ent 1 2 1 12
ent2 36 2 444
ent3 63 365 111
ent4 3 2 545
avril mai juin
ent1 1 2 23
ent2 2 36 22
ent3 5 252 22
ent4 2 2 214

My probleme is with the data capture.

This the code
Charts.Add
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _
"Courbe - Histo. 2 axes"
ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("B2:E6"), PlotBy:=
_
xlRows
ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil2"
I think taht the "RAnge("B2:E5")" must not be fixed but it could be like
"Range("case1:case2")",
With case1=A2 then case1=A2+5 i.e. case1=A7
Like wise for case2=E5 then case2=E5+5 i.e. casee2=E10

The number of source data is not fixed, the function had to stop when it is no
more value.
I try to do somethong like:
"Ifcase1<Activesheet.UsedRange.Rows.Count then go to begin" with begin tehe
beginning of the buckle,but i need the field "case1".

So if need be, i can give you an example.
Thanks for your help
Elve

PS: excuse me if my english is not perfect i am french...
 
Elve -

One simplistic way is to use the Offset property of Range. At some
point you can define the value of the integer iChart, and let it equal 1
for the first chart, etc. then change Range("B2:E6") in your code to

Range("B2:E6").Offset((iChart - 1) * 5)

There are more detailed ways to do this that either edit the text of the
range reference or define range variables.

- Jon
 
Back
Top