Sub Essai_boucle2()
Dim k As Integer
Dim lot As Integer
Dim bool As Boolean
Dim lig As Integer
Dim num_lot%, code_pf%, pays%, present%, date_fab%, date_peremp%
Application.ScreenUpdating = False
' Recherche des coordonnées des colonnes sur la feuille en cours (je suppose que tu es tjs en ligne 5)
num_lot = ActiveCell.Column
For j = 1 To Range("IV5").End(xlToLeft).Column
If InStr(1, LCase(Cells(5, j).Value), "code pf") > 0 Then
code_pf = j
ElseIf InStr(1, LCase(Cells(5, j).Value), "pays") Then
pays = j
ElseIf InStr(1, LCase(Cells(5, j).Value), "présentation") Then
present = j
ElseIf InStr(1, LCase(Cells(5, j).Value), "fabrication") Then
date_fab = j
ElseIf InStr(1, LCase(Cells(5, j).Value), "péremption") Then
date_peremp = j
End If
Next j
lot = ActiveCell.Value
bool = False
With Sheets("Synthèse")
.Range("D6").ClearContents
.Range("D10" & ":" & "D103").ClearContents
End With
For k = 6 To Cells(65536, num_lot).End(xlUp).Row
If Cells(k, num_lot).Value = lot Then
If bool = False Then
With Sheets("Synthèse")
.Range("D6") = Range("D1")
.Range("D10") = lot
.Range("D12") = Format(Cells(k, date_fab), "mmm yyyy")
lig = 16
bool = True
End With
End If
With Sheets("Synthèse")
.Range("D" & lig) = Cells(k, pays)
.Range("D" & lig + 2) = Cells(k, present)
.Range("D" & lig + 4) = Cells(k, code_pf)
.Range("D" & lig + 6) = Format(Cells(k, date_peremp), "mmm yyyy")
lig = lig + 9
End With
End If
Next k
Application.ScreenUpdating = True
End Sub