1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| Sub MonVlookupQuiFonctionneFinalement()
Dim rng As Range
Dim i As Long
Application.ScreenUpdating = False
Worksheets("Sheet2").Activate
Range("A1").Activate
With Worksheets("Sheet2").Cells
Set rng = .Range("A1:A" & .Cells(.Rows.Count, 1).End(xlUp).Row)
For i = 1 To rng.Rows.Count
rng.Cells(i, 2) = Application.VLookup(.Cells(i, 1), Sheets("Sheet1").Range("A:B"), 2, False)
If IsError(rng.Cells(i, 2)) Then
If rng.Cells(i, 2) = CVErr(xlErrNA) Then ' Pour changer le "#NA" en to "Doublon ou Pas trouvé" le cas échéant.
rng.Cells(i, 2) = "Doublon ou Pas trouvé"
End If
End If
Next
End With
Set rng = Nothing
Application.ScreenUpdating = True
End Sub |