Sub mef_tablo()
Dim derligne%, i%, t0
t0 = Timer
'--- suppression feuille "fin"
Application.DisplayAlerts = False
Application.ScreenUpdating = False
For i = Sheets.Count To 2 Step -1
If Sheets(i).Name = "fin" Then Sheets(i).Delete: Exit For
Next i
'--- ajout de lignes
derligne = Cells(Rows.Count, 1).End(3).Row
Sheets(1).Copy After:=Sheets(1)
ActiveSheet.Name = "fin"
derligne = Cells(Rows.Count, 1).End(3).Row
On Error Resume Next
For i = derligne To 2 Step -1
If Cells(i, 1) <> Cells(i - 1, 1) Then
Cells(i, 1).EntireRow.Insert (3)
Cells(i, 1).EntireRow.Insert (3)
End If
Next i
'--- ajout de textes pour chaque partie (colonne C = 3 = référence de recherche)
derligne = Cells(Rows.Count, 1).End(3).Row
For i = derligne To 2 Step -1
If (Cells(i, 3) = "" And Cells(i - 1, 3) = "") Then
Cells(i, 3) = Cells(i + 2, 2): Cells(i, 3) = Cells(i, 3)
Cells(i - 1, 3) = Cells(i + 2, 1): Cells(i - 1, 3) = Cells(i - 1, 3)
Else
End If
Next i
'--- mise en forme (sur colonne D = 4 = vide)
For i = derligne To 2 Step -1
If Cells(i, 4) = "" Then
With Range("C" & i & ":F" & i) '--- ta demande : sur 4 colonnes : C, D, E et F donc si tu rajoutes une colonne, change tes bornes
.MergeCells = True
.HorizontalAlignment = xlCenter
.FormatConditions.Delete
.Interior.ColorIndex = 44
.Interior.Pattern = xlSolid
.Font.Bold = True
End With
End If
If Cells(i, 3) Like "*-*" Then
With Range("C" & i & ":F" & i)
.Borders(xlEdgeTop).Weight = xlThick
End With
End If
Next i
'--- suppression colonnes A et B et enregistrement
Columns("A:B").Delete Shift:=xlToLeft
Call efface_shape
ActiveWorkbook.Save
Application.ScreenUpdating = True
MsgBox Format(Timer - t0, "0.000\sec")
End Sub