Bonjour,
Je cherche à faire une recherche verticale dans des fichiers différents.
Pouvez-vous jeter un oeil à mon programme? Celui-ci ne fonctionne pas avec un message d'erreur "Erreur définie par l'application ou par l'objet"
Dim x As Variant
Set a = Workbooks("Testchangements.xlsm").Sheets("Feuil1")
Set b = Workbooks("Avril.xlsx").Sheets("Entrants")
For i = 4 To 327
x = Application.VLookup(a.Cells(i, 21).Value, b.Range(Cells(2, 4), Cells(15, 10)), 1, False)
If IsError(x) Then
Workbooks("Testchangements.xlsm").Sheets("Feuil1").Cells(i, 21) = ""
Else
a.Cells(i, 21) = Application.VLookup(a.Cells(i, 21).Value, b.Range(Cells(2, 4), Cells(222, 14)), 1, False) 'Matricule
a.Cells(i, 21 + 1) = Application.VLookup(a.Cells(i, 21).Value, b.Range(Cells(2, 4), Cells(222, 14)), 10, False)
a.Cells(i, 21 + 2) = Application.VLookup(a.Cells(i, 21).Value, b.Range(Cells(2, 4), Cells(222, 14)), 6, False) 'Emploi
End If
Next i
End Sub