Option Base 1
Sub creationGraph()
Dim id$, T(), cht As ChartObject
Dim x%, col As Byte, i As Byte, j As Byte
Dim c As Range, rng As Range
x = 1
col = 20
id = UCase(InputBox("Identification du process:", "Bilan mensuel process"))
If id = "" Then Exit Sub
ReDim Preserve T(1 To 13, x)
For i = 1 To 12
T(i + 1, 1) = MonthName(i)
Next
Set rng = Range("O8:S33")
Set c = rng.Find(id)
If Not c Is Nothing Then
Adresse = c.Address
Do
x = x + 1
ReDim Preserve T(1 To 13, 1 To x)
T(1, x) = Cells(c.Row, 1)
For j = 2 To 13
T(j, x) = Cells(c.Row, col)
col = col + 5
Next
col = 20
Set c = rng.FindNext(c)
Loop While Not c Is Nothing And c.Address <> Adresse
Else: Exit Sub
End If
With Sheets("Graphiques")
.Range("A1").Resize(UBound(T, 2), UBound(T, 1)) = Application.Transpose(T)
Set rng = .Range("A1:M" & UBound(T, 2))
Set cht = .ChartObjects.Add(10, 10, 400, 300)
With cht.Chart
.SetSourceData Source:=rng, PlotBy:=xlRows
.ChartType = xlCylinderColClustered
.HasTitle = True
.ChartTitle.Text = "Bilan mensuel process " + id
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Mois de l'année"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "kWh"
End With
End With
End Sub