1
I have a spreadsheet where column A has following values (1,2,4,6,8,10), and the fields with value 1 should be the sum of all groups 2 below it until the next value with field 1, and group 2 shall be the sum of all values of group 4 below it to the next cell with value 2, and so on to group 8, which shall be the sum of all values 10 below it.
I have already created a structure for all the values of 8 to be filled, but the totalizers of 1 to 6, as they are not continuous, I am not being able to 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
Thank you very much Felipe, as the database has several columns, I thought to leave the cell filled as formula, so that it was easy to replicate to the other columns of the table, as you mentioned I would have to replicate the fill for many columns, which would take a long time. The above formula fills cells with a sum formula, after which my macro copies the same formula and drags to the other columns.
– Mrso