Bonjour,
tous passe par les conditions dans la macro,
Sub test1()
'reste à déclarer les variables...
Set sh1 = Sheets("Feuil1")
Set sh2 = Sheets("Feuil2")
lastRow1 = sh1.Cells(Rows.Count, 1).End(xlUp).Row
sh1.Range("A:A").Replace What:=" ml", Replacement:="ml", LookAt:=xlPart
sh2.Activate
For i = 1 To lastRow1
col = col + 1
sh1.Cells(i, 1) = Trim(sh1.Cells(i, 1))
If Left(sh1.Cells(i, 1), 6) = "LIGNE" Then
lastRow2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row + 1
col = 1
End If
If sh1.Cells(i, 1) = "DEBUT CONTROLE:" Or sh1.Cells(i, 1) = "FIN CONTROLE:" Then
sh2.Cells(lastRow2, col) = CDate(sh1.Cells(i + 1, 1))
GoTo prochain
End If
If Left(sh1.Cells(i, 1), 5) = " LOT" Then
GoTo prochain
End If
If sh1.Cells(i, 1) = "" Or sh1.Cells(i, 1) = "------------------------" Then
GoTo prochain
End If
For n = Len(sh1.Cells(i, 1)) To 1 Step -1
c = Mid(sh1.Cells(i, 1), n, 1)
If c = Chr(32) Then
sh2.Cells(lastRow2, col) = Right(sh1.Cells(i, 1), Len(sh1.Cells(i, 1)) - n)
GoTo prochain
End If
Next n
prochain:
Next i
MsgBox "Fin de traitement"
End Sub