1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
Sub traitement()
Dim i As Integer
Dim nbreVal, sommeVal, sommeVal1, sommeVal2, sommeVal4, sommeVal5, sommeVal6 As Double
Dim Val3 As Long
Dim strAct As String
i = 2
nbreVal = 0
sommeVal = 0
strAct = Cells(i - 1, 3).Value
While Trim(Cells(i - 1, 3).Value) <> ""
If Cells(i, 3).Value <> strAct Then
Rows(i & ":" & i).Select
Selection.Insert Shift:=xlDown
Cells(i, 3).Value = strAct
Cells(i, 4).Value = sommeVal
Cells(i, 5).Value = sommeVal1
Cells(i, 6).Value = sommeVal2
Cells(i, 7).Value = Val3
Cells(i, 9).Value = sommeVal4
Cells(i, 10).Value = sommeVal5
nbreVal = 0
sommeVal = 0
sommeVal1 = 0
sommeVal2 = 0
Val3 = 0
sommeVal4 = 0
sommeVal5 = 0
strAct = Cells(i + 1, 3).Value
Else
nbreVal = nbreVal + 1
sommeVal = sommeVal + Cells(i, 4).Value
sommeVal1 = sommeVal1 + Cells(i, 5).Value
sommeVal2 = sommeVal2 + Cells(i, 6).Value
Val3 = (1 - (Cells(i, 5).Value / Cells(i, 6).Value))
sommeVal4 = sommeVal4 + Cells(i, 9).Value
sommeVal5 = sommeVal5 + Cells(i, 10).Value
End If
i = i + 1
Wend
Rows(i & ":" & i).Select
Selection.Insert Shift:=xlDown
Cells(i, 3).Value = strAct
Cells(i, 4).Value = sommeVal
Cells(i, 5).Value = sommeVal1
Cells(i, 6).Value = sommeVal2
Cells(i, 7).Value = Val3
Cells(i, 9).Value = sommeVal4
Cells(i, 10).Value = sommeVal5
End Sub |
Partager