Sub CréerGraphique()
Dim F As Worksheet, plage As Range, rc&, cc%, a, i&, j%
Set F = ActiveSheet
Set plage = F.[D2:W205] 'à adapter
rc = plage.Rows.Count
cc = plage.Columns.Count
ReDim a(1 To cc) 'tableau auxiliaire
Application.ScreenUpdating = False
On Error Resume Next
F.ChartObjects.Delete 'RAZ
On Error GoTo 0
Charts.Add
ActiveChart.ChartType = xlXYScatterSmooth
ActiveChart.Location xlLocationAsObject, F.Name
With ActiveChart
For i = .SeriesCollection.Count To 1 Step -1
.SeriesCollection(i).Delete 'RAZ
Next
For i = 1 To rc
For j = 1 To cc
a(j) = rc + 1 - i
Next
With .SeriesCollection.NewSeries
.XValues = plage.Rows(i)
.Values = a
.MarkerStyle = xlSquare 'à adapter
.MarkerSize = 6 'à adapter
.MarkerBackgroundColorIndex = plage(i, -1)
.MarkerForegroundColorIndex = plage(i, -1)
plage(i, -1).Interior.ColorIndex = plage(i, -1) 'colore la colonne B
.Format.Line.ForeColor.RGB = plage(i, -1).Interior.Color
End With
Next
.Axes(xlCategory).MinimumScale = 0
.Axes(xlValue).MinimumScale = 0
.Axes(xlValue).MaximumScale = rc + 1
.Axes(xlValue).HasMajorGridlines = False
.HasAxis(xlValue, xlPrimary) = False
.Parent.Top = 0: .Parent.Left = 0 'en haut à gauche
.Parent.Height = 25 * rc + 75 'hauteur du graphique
.Parent.Width = 415 'largeur du graphique
End With
F.[A1].Activate 'facultatif
End Sub