Sub Traitement()
Dim TabTemp As Variant
Dim L As Long, L2 As Long, Pos As Long
'Charge les données dans un tableau variant temporaire
With Sheets('Pièces')
L = .Range('D65536').End(xlUp).Row
TabTemp = .Range(.Cells(1, 1), .Cells(L, 4)).Value
'
Pos = UBound(TabTemp, 1)
For L = UBound(TabTemp, 1) To 1 Step -1
If Trim(TabTemp(L, 4)) = '' Then
'Sous-Titre rencontré
If TabTemp(L, 2) <> '' Then
.Range(.Cells(L + 1, 5), .Cells(Pos, 5)).Value = TabTemp(L, 2)
Pos = L - 1
End If
'Supprime la ligne
If L > 1 Then .Rows(L).Delete
End If
Next L
'Nouvelle zone de titre
For L = 1 To 5
.Cells(1, L).Value = Choose(L, 'Code', 'Description', '', 'HT', 'Catégorie')
Next L
'Mise en forme colonne E
.Columns(3).Copy
.Columns(5).PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
.Columns(5).AutoFit
.Range('A1').Select
End With
Application.Dialogs(xlDialogSaveAs).Show 'FichierTraité.xls'
End Sub