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
| Dim DerCel As Long
DerCel = Worksheets("Sheet1").Range("A65536").End(xlUp).Row
'Cells(1, 1) = DerCel
Dim i As Integer
Dim subtotal As Variant
subtotal = Cells(1, 2)
For i = 1 To DerCel
If Cells(i, 1) = Cells(i + 1, 1) Then
subtotal = subtotal + Cells(i + 1, 2)
Else: Cells(i, 3) = "subtotal for strategy" & " " & Cells(i, 1).Text & " ="
Cells(i, 4) = subtotal
subtotal = Cells(i + 1, 2)
End If
Next i
Dim j As Integer
Dim k As Integer
k = 1
For j = 1 To DerCel
If Cells(j, 4) <> Empty Then
Cells(k, 5) = Cells(j, 4)
k = k + 1
Else: End If
Next j
End Sub |
Partager