Sub TriBloc()
Dim derlig1&, derlig2, i&, ref
Application.ScreenUpdating = False
If Me.FilterMode Then Me.ShowAllData
derlig1 = Cells(Rows.Count, "a").End(xlUp).Row
Range("g1") = "Aide au tri"
Range("g2").FormulaR1C1 = "=IF(R[-1]C[-6]="""",SUM(R[-1]C,1),SUM(R[-1]C,0))"
Range("g2:g" & derlig1).FillDown
Range("g2:g" & derlig1) = Range("G2:G" & derlig1).Value
Range("a1:g" & derlig1).Sort key1:=Range("a1"), order1:=xlAscending, Header:=xlYes
derlig2 = Cells(Rows.Count, "a").End(xlUp).Row
If derlig2 < derlig1 Then Range(Cells(derlig2 + 1, "g"), Cells(derlig1, "g")).Clear
ref = Cells(derlig2, "g")
For i = derlig2 To 3 Step -1
If Cells(i - 1, "g") <> ref Then ref = Cells(i - 1, "g"): Rows(i).Insert
Next i
Range("g:g").Clear
End Sub