Dim cel As Range, couleur& 'mémorise les variables
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range, colPasse$, colPoints$
Set r = [J4:J10] 'plage à adapter
colPasse = "E" 'à adapter
colPoints = "H" 'à adapter
DrawingObjects.Delete 'RAZ
On Error Resume Next 'si la cellule ne peut être touvée
For Each r In r
If r <> "" Then
Set cel = Nothing 'réinitialise
couleur = r.Interior.Color
MaSelection r.MergeArea 'car cellule fusionnée
MaSelection Columns(colPoints).Find(r(1, 3), , xlValues, xlWhole)
MaSelection Columns(colPasse).Find(r(1, 2))
End If
Next
End Sub
Sub MaSelection(Target As Range)
If Not cel Is Nothing Then _
Shapes.AddLine(cel.Left, cel.Top + cel.Height / 2, Target.Left + Target.Width, Target.Top + Target.Height / 2) _
.Line.ForeColor.RGB = couleur
Set cel = Target
End Sub