I have a worksheet where column A has following values values (1,2,4,6,8,10), the fields with value 1 must be the sum of all groups 2 below it until the next value with field 1, and group 2 should be the sum of all values from group 4 below it to the next cell with value 2, and so on up to group 8, which will be the sum of all values 10 below it .
I have already created a structure for all values of 8 to be filled, but the totals from 1 to 6, as they are not continuous, I can not add.
For i = 1 To b
If balancete.Cells(i + 1, 1) = 10 Then
cont_10 = cont_10 + 1
ElseIf balancete.Cells(i + 1, 1) <> 10 Then
If balancete.Cells(i, 1) = 10 Then
balancete.Cells(i - cont_10, 4) = "=SOMA(D" & i + 1 - cont_10 & ":D" & i & ")"
cont_10 = 0
End If
Else
i = i + 1
End If
Next i