Chemin = ThisWorkbook.Path ' même dossier
Set Ws_Source = Worksheets("liste")
With Ws_Source
TabListe = Selection
' TabListe = .Range("A3:A" & .Range("A65536").End(xlUp).Row).Value
End With
Workbooks.Open Chemin & "\BD-080209.xls"
With ActiveWorkbook
With .Worksheets("EMPL")
DerLigne = .Range("A1").End(xlDown).Row
Tabtemp = .Range(.Cells(2, 1), .Cells(DerLigne, 4)).Value
End With
With .Worksheets("ARTICLE")
DerLigne2 = .Range("D1").End(xlDown).Row
Tabtemp2 = .Range(.Cells(2, 4), .Cells(DerLigne2, 4)).Value
End With
.Close
End With
' -------------------------------------------- Récupération de la localisation -----------------------------------------
x = 0
For Ligne = 1 To UBound(TabListe, 1) 'pour chaque element du tableau liste
For L = 1 To UBound(Tabtemp, 1) 'pour chaque ligne du tableau bd
If Tabtemp(L, 1) = TabListe(Ligne, 1) Then 'si egalite en colonne 1
x = x + 1
ReDim Preserve TabRecup(4, x) 'on redimensionne le tableau de récupération
For Col = 1 To 4 'ici on boucle sur les colonne de la ligne trouvée
TabRecup(Col, x) = Tabtemp(L, Col)
Next
End If
Next
Next
With Worksheets("try")
DerLigne = .Range("A65536").End(xlUp).Row + 1
.Range(.Cells(2, 1), .Cells(DerLigne, 4)).ClearContents
.Range("A2").Resize(UBound(TabRecup, 2), UBound(TabRecup, 1)) = Application.Transpose(TabRecup)
End With