1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Sub Comparer()
Dim DCel As Range, TbL1, TbL2, Resultat()
Dim x As Long, y As Long
With Worksheets("Feuil1")
Set DCel = .Range("A" & .Rows.Count).End(xlUp)
TbL1 = .Range("A2", DCel)
ReDim Resultat(1 To UBound(TbL1, 1))
With Worksheets("Feuil2")
Set DCel = .Range("A" & .Rows.Count).End(xlUp)
TbL2 = .Range("A2", DCel)
End With
For x = 1 To UBound(TbL1, 1)
For y = 1 To UBound(TbL2, 1)
If TbL1(x, 1) = TbL2(y, 1) Then
Resultat(x) = TbL2(y, 1)
Exit For
Else
Resultat(x) = "NP"
End If
Next y
Next x
.Range("B2").Resize(UBound(TbL1, 1)) = Application.Transpose(Resultat)
End With
End Sub |