1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| Option Explicit
Sub graphique()
Dim i As Integer
Dim dern_ligne As Integer
dern_ligne = Range("A65536").End(xlUp).Row
Dim date_origine As Integer
date_origine = 1
Dim date_evol As Integer
date_evol = 1
Dim rSource As Range
Dim rSource_eff As Range
'ligne ou apparaît la date d'origine
While Cells(date_origine, 1).Value <> "Date origine"
date_origine = date_origine + 1
Wend
'ligne ou apparaît la date d'évolution
While Cells(date_evol, 1).Value <> "date évolution"
date_evol = date_evol + 1
Wend
Set rSource = Union(Cells(date_evol, 1), Cells(date_evol, 4))
Set rSource_eff = Cells(date_evol, 5)
'source de données
For i = 1 To dern_ligne - date_evol
Set rSource = Union(rSource, Range(Cells(date_evol, 1), Cells(date_evol + i, 1)), _
Range(Cells(date_evol, 4), Cells(date_evol + i, 4)))
Set rSource_eff = Union(rSource_eff, Range(Cells(date_evol, 5), Cells(date_evol + i, 5)))
Next i
'graphique
Charts.Add
ActiveChart.SetSourceData Source:=rSource, PlotBy:=xlColumns
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(2).Values = rSource_eff
'type : graphique avec deux courbes et deux ordonnées
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, _
TypeName:="courbes à deux axes"
'lieu du graphique
ActiveChart.Location where:=xlLocationAsObject, Name:="feuil2"
End Sub |
Partager