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 42 43 44
| Public Sub ESSAI()
Dim c As Range
Dim f As Range
Dim col_photo As Range
Dim col_recherche As Range
Dim feuille_recherche As Worksheet
'Affectation de variables aux colonnes à balayer et recherche
With ThisWorkbook.Sheets(1)
Set col_photo = .Range(.Range("A2"), .Cells(.Rows.Count, 1).End(xlUp))
End With
Set feuille_recherche = Workbooks("suivi - Info - clc - u202213.-.xlsx").Sheets("photo a effectuer")
With feuille_recherche
Set col_recherche = .Range(.Range("D2"), .Cells(.Rows.Count, 4).End(xlUp))
End With
'Boucle sur les numéros de série du 1er classeur
For Each c In col_photo
Set f = col_recherche.Find(c, Lookat:=xlWhole)
'Si c absent, la ligne d'informations = 1ère ligne vide
If f Is Nothing Then
ligne = col_recherche.End(xlDown).Offset(1, 0).Row
Else
'Si c présent, la ligne d'informations est celle trouvée
ligne = f.Row
End If
'Informations dans le 2nd classeur
With feuille_recherche
'Colonne A, Passons outre la redondance en cas de succès
.Cells(ligne, 4) = c.Value
'Colonne F = Colonne B
.Cells(ligne, 5) = c.Offset(0, 1)
'etc pour toutes les colonnes
End With
Next c
'Réinitialisation des variables
Set col_photo = Nothing
Set feuille_recherche = Nothing
Set col_recherche = Nothing
Set f = Nothing
End Sub |
Partager