Dim tablo() 'mémorise
Private Sub Worksheet_Activate()
Dim F1 As Worksheet, F2 As Worksheet, lig&, t1, t2, n&
Set F1 = Feuil1 'CodeName
Set F2 = Feuil2 'CodeName
lig = 3 '1ère ligne étudiée
t1 = F1.Cells(lig, 1).Resize(F1.Cells(F1.Rows.Count, 1).End(xlUp).Row, 2)
t2 = F2.Cells(lig, 1).Resize(F2.Cells(F2.Rows.Count, 1).End(xlUp).Row, 2)
n = UBound(t1) + UBound(t2)
ReDim tablo(1 To n, 1 To 5)
Remplissage t1, t2, 0, UBound(t1), lig, 3
Remplissage t2, t1, UBound(t1), 0, lig, 4
'---restitution---
[A2].Resize(n, 4) = tablo
[A2].Resize(n, 4).Sort [A2], xlAscending, Header:=xlNo 'tri indispensable
Range("A" & n + 2 & ":D" & Rows.Count).ClearContents
n = Me.UsedRange.Rows.Count 'ajustement de la barre de défilement verticale
End Sub
Sub Remplissage(t1, t2, decal1&, decal2&, lig&, col As Byte)
Dim fin&, i&, x$, j&
fin = UBound(t2)
For i = 1 To UBound(t1)
If IsEmpty(tablo(i + decal1, 5)) Then
x = t1(i, 1) & Chr(1) & t1(i, 2)
For j = 1 To fin
If IsEmpty(tablo(j + decal2, 5)) Then
If x = t2(j, 1) & Chr(1) & t2(j, 2) Then
tablo(i + decal1, 5) = 1
tablo(j + decal2, 5) = 1
GoTo 1
End If
End If
Next
tablo(i + decal1, 1) = t1(i, 1)
tablo(i + decal1, 2) = t1(i, 2)
tablo(i + decal1, col) = lig + i - 1
End If
1 Next
End Sub