Private Sub Worksheet_Calculate()
'le tableau T définit les textes et les couleurs des Shapes
Dim x1, y1, x2, y2, x3, y3, x4, y4, x5, y5
With ChartObjects(1).Chart
.SeriesCollection(1).Points(1).Select: x1 = Selection.Left: y1 = Selection.Top
.SeriesCollection(1).Points(2).Select: x2 = Selection.Left: y2 = Selection.Top
.SeriesCollection(1).Points(3).Select: x3 = Selection.Left: y3 = Selection.Top
.SeriesCollection(1).Points(4).Select: x4 = Selection.Left: y4 = Selection.Top
.SeriesCollection(1).Points(5).Select: x5 = Selection.Left: y5 = Selection.Top
With .Shapes("Rectangle 1")
.Width = x2 - x1: .Height = y1 - y4 'dimensionner d'abord
.Left = x1: .Top = y4
.TextFrame2.TextRange.Characters.Text = [T].Cells(1)
.Fill.ForeColor.RGB = [T].Cells(1, 3).Interior.Color
End With
With .Shapes("Rectangle 2")
.Width = x3 - x2: .Height = y1 - y4 'dimensionner d'abord
.Left = x2: .Top = y4
.TextFrame2.Orientation = msoTextOrientationUpward 'msoTextOrientationHorizontal
.TextFrame2.TextRange.Characters.Text = [T].Cells(2, 1)
.Fill.ForeColor.RGB = [T].Cells(2, 3).Interior.Color
End With
With .Shapes("Rectangle 3")
.Width = x3 - x1: .Height = y4 - y5 'dimensionner d'abord
.Left = x1: .Top = y5
.TextFrame2.TextRange.Characters.Text = [T].Cells(3, 1)
.Fill.ForeColor.RGB = [T].Cells(3, 3).Interior.Color
End With
End With
ActiveCell.Activate
ThisWorkbook.Saved = True 'évite l'invite à la fermeture
End Sub