Sub Essai()
Dim Ligne As Long
Application.ScreenUpdating = False
With Sheets("A")
LastLine = .Range("A" & .Rows.Count).End(xlUp).Row
For Ligne = LastLine To 3 Step -1
If .Range("A" & Ligne) <> .Range("A" & Ligne - 1) Then
.Range("A" & Ligne).EntireRow.Insert
End If
Next Ligne
LastLine = .Range("A" & .Rows.Count).End(xlUp).Row + 1
TabData = .Range("A1").Resize(LastLine, 3).Value
For i = LBound(TabData, 1) + 1 To UBound(TabData, 1)
If TabData(i, 1) = "" Then
TabData(i, 1) = "Total"
TabData(i, 3) = Total
Total = 0
Else
Total = Total + TabData(i, 3)
End If
Next i
.Range("A1").Resize(LastLine, 3) = TabData
End With
Range("A2").Resize(LastLine, 3).Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=A2=""Total"""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Application.CutCopyMode = False
Application.ScreenUpdating = False
End Sub