Private Sub Worksheet_Change(ByVal Target As Range)
Dim cible, i As Variant, tablo, ub&, j&, k&
If FilterMode Then ShowAllData 'si la feuille est filtrée
With Range("A4:B" & Range("A" & Rows.Count).End(xlUp).Row - 1)
If .Row < 4 Then Exit Sub
If Intersect(Target, [E4]) Is Nothing Then Exit Sub
.Columns(2).Interior.ColorIndex = xlNone 'RAZ
cible = [E4]
If Not IsNumeric(CStr(cible)) Then Exit Sub
tablo = .Value 'matrice, plus rapide
ub = UBound(tablo)
'---1 2 ou 3 factures rapprochées---
For i = 1 To ub
If tablo(i, 2) = cible Then .Cells(i, 2).Interior.Color = vbGreen: Exit Sub
For j = i + 1 To ub
If tablo(i, 2) + tablo(j, 2) = cible Then Union(.Cells(i, 2), .Cells(j, 2)).Interior.Color = vbGreen: Exit Sub
For k = j + 1 To ub
If tablo(i, 2) + tablo(j, 2) + tablo(k, 2) = cible Then Union(.Cells(i, 2), .Cells(j, 2), .Cells(k, 2)).Interior.Color = vbGreen: Exit Sub
Next k, j, i
End With
End Sub