Sub main()
Sheets("DONNEES").Select
RowCount = Cells(Cells.Rows.Count, "a").End(xlUp).Row
For r = 2 To RowCount
Sheets("DONNEES").Select
Range("G" & r).Select
marge = ActiveCell.Value
Range("E" & r).Select
ca = ActiveCell.Value
txmarge = (marge / ca)
txmarge = Round(txmarge, 2)
If txmarge < 0.26 Then
Rows(r).Copy
Sheets("SYNTHESE").Select
RowCount = Cells(Cells.Rows.Count, "a").End(xlUp).Row
Range("A" & RowCount + 1).PasteSpecial (xlPasteValues)
Range("H" & RowCount + 1).Select
ActiveCell.Value = txmarge
End If
Next r
Call sort
Call totalise
End Sub
Sub totalise()
Sheets("SYNTHESE").Select
RowCount = Cells(Cells.Rows.Count, "a").End(xlUp).Row
For L = RowCount To 3 Step -1
Range("a" & L).Select
var1 = Range("a" & L - 1).Value
Range("a" & L - 1).Select
var2 = Range("a" & L).Value
If var1 <> var2 Then
a = ActiveCell.Row
' MsgBox a
Range("a" & a).Select
ActiveCell.Offset(1).EntireRow.Insert
' Range("A" & a + 3).Select
' ActiveCell.Value = "Total"
' ActiveCell.Offset(rowOffset:=0, columnOffset:=4).Activate
End If
Next L
End Sub
Sub sort()
Sheets("SYNTHESE").Select
Range("a2").Select
Application.CutCopyMode = False
Selection.sort Key1:=Range("a2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
' Selection.AutoFilter
End Sub