Voici le Nouveau code:
Sub Importation_Tri()
Dim f1 As Worksheet, f2 As Worksheet
Dim i As Long, DerLig_f1 As Long
Application.ScreenUpdating = False
Set f1 = Sheets("Feuil1")
Set f2 = Sheets("Feuil2")
f2.Cells.Clear 'effacement des précédentes importations triées
DerLig_f1 = f1.Range("A1").CurrentRegion.Rows.Count 'Dernière ligne de la feuille "Pro"
Range(f2.Cells(1, "A"), f2.Cells(DerLig_f1, "O")).Value = Range(f1.Cells(1, "A"), f1.Cells(DerLig_f1, "O")).Value 'Copie du tableau dans la feuille "Apres_Tri"
For i = DerLig_f1 To 2 Step -1
If f2.Cells(i, "A") = "" And f2.Cells(i - 1, "A") <> "" Then
Range(f2.Cells(i, "A"), f2.Cells(i, "G")).Value = Range(f2.Cells(i, "H"), f2.Cells(i, "N")).Value 'Déplacement des données
ElseIf f2.Cells(i, "A") = "" And f2.Cells(i, "I") <> "" Then
Range(f2.Cells(i, "A"), f2.Cells(i, "G")).Value = Range(f2.Cells(i, "H"), f2.Cells(i, "N")).Value 'Déplacement des données
i = i - 1
End If
Next i
f2.Columns("I:J").Delete 'Suppression des données inutiles"
Range(f2.Cells(2, "H"), f2.Cells(DerLig_f1, "N")).ClearContents
Set f1 = Nothing
Set f2 = Nothing
End Sub
le fichier
Cdlt