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 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| Sub Macro_Recherche()
Dim rngArticle As Range, rngArticleRecherche As Range, rngRefTrouve As Range, Cell As Range
Dim xlWs As Worksheet, myWs As Worksheet
Dim xlWk As Workbook
Dim DerLig As Long
Dim i As Integer
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
Set xlWk = Workbooks.Open(Chemin_Dossier & Dossier_Sources)
Set xlWs = xlWk.Worksheets(1)
Set myWs = ThisWorkbook.Worksheets("Feuill1-classeur1")
With myWs
For i = 11 To 81 Step 5
DerLig = .Cells(.Rows.Count, i).End(xlUp).Row
Set rngArticle = .Range(.Cells(4, i), .Cells(DerLig, i))
'Recherche de l'article dans l'autre fichier
Set rngArticleRecherche = xlWs.Range(xlWs.Range("A2"), xlWs.Cells(.Rows.Count, 1).End(xlUp)) 'ICI LA COLONNE RECHERCHE
For Each Cell In rngArticle
Set rngRefTrouve = rngArticleRecherche.Find(Cell.Value, , xlValues, xlWhole)
If Not rngRefTrouve Is Nothing Then Cell.Offset(, 1).Value = rngRefTrouve.Offset(, 6).Value
Next Cell
Next i
End With
Set myWs = Nothing
Set xlWs = Nothing
xlWk.Close False
Set xlWk = Nothing
MsgBox "Triatement terminé!"
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub |
Partager