Bonjour,
ok.
Version qui te coche les anomalies dans une 3ème colonne :
Sub traiter()
Dim Dict, c As Variant, pl() As Variant
Dim lig As Long, derlig As Long, tmp As String, ano As Long
Set Dict = CreateObject("Scripting.Dictionary")
derlig = [A:B].Cells.Find("*", , , , xlByRows, xlPrevious).Row
With [C2:E2].Resize(Rows.Count - 1)
.ClearContents
.Interior.ColorIndex = xlNone
End With
pl = [A2].Resize(derlig - 1, 3).Value
For lig = 1 To derlig - 1
If pl(lig, 1) <> "" Then
If Not Dict.exists(pl(lig, 1)) Then
Dict(pl(lig, 1)) = 1
End If
End If
If pl(lig, 2) <> "" Then
If Not Dict.exists(pl(lig, 2)) Then
Dict(pl(lig, 2)) = 2
End If
End If
Next lig
For lig = 1 To derlig - 1
If pl(lig, 1) <> "" And pl(lig, 2) <> "" And Dict(pl(lig, 1)) = Dict(pl(lig, 2)) Then
ano = ano + 1
Cells(lig + 1, 3).Resize(, 2).Interior.ColorIndex = 6
pl(lig, 3) = "x"
ElseIf (pl(lig, 1) <> "" And Dict(pl(lig, 1)) <> 1) Or (pl(lig, 2) <> "" And Dict(pl(lig, 2)) <> 2) Then
tmp = pl(lig, 1)
pl(lig, 1) = pl(lig, 2)
pl(lig, 2) = tmp
pl(lig, 3) = ""
End If
Next lig
[c2].Resize(derlig - 1, 3) = pl
If ano > 1 Then MsgBox ano & " anomalies mises en jaune."
End Sub
eric