Dim I As Integer
Dim J As Integer
Dim K As Integer
Dim L As Boolean
Dim DerLig As Long
If Target.Address = "$C$4" Then
With Range("D50:H52")
.Interior.ColorIndex = xlNone
.ClearContents
End With
Range("D55:H56").ClearContents
If Target.Value = "" Then Exit Sub
With Worksheets("Table_recette")
DerLig = .Range("A" & Rows.Count).End(xlUp).Row
With .Range("B2:B" & DerLig)
Set c = .Find(Target.Value, LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
FirstAddress = c.Address
I = 0
Do
Cells(50, I + 4).Value = c.Offset(0, -1).Value
Cells(55, I + 4).Value = c.Offset(0, 2).Value
Set c = .FindNext(c)
I = I + 1
Loop While Not c Is Nothing And c.Address <> FirstAddress
Range("D50:D52").Interior.ColorIndex = 53
With Range("D50")
K = 0
For I = 1 To 4
L = False
If .Offset(0, I).Value <> "" Then
For J = 0 To I - 1
If Left$(.Offset(0, I).Value, 3) = Left$(.Offset(0, J).Value, 3) Then
L = True
Range("D50:D52").Offset(0, I).Interior.ColorIndex = Range("D50:D52").Offset(0, J).Interior.ColorIndex
Exit For
End If
Next
If Not L Then
K = K + 1
Range("D50:D52").Offset(0, I).Interior.ColorIndex = Choose(K, 42, 36, 43, 22)
End If
End If
Next
End With
End If
End With
End With
End If