SOLVED

Ignore repeated identifiers

Copper Contributor

Hello,
I created a macro which allows to compare the identifiers of two cells:
- if the identifiers are equal, it makes the sum of flow
- if not, the flow remains constant

For ligne = 3 To 9214

If Cells(ligne, 2) = Cells(ligne + 1, 2) Then
Cells(ligne, 7).Value = Cells(ligne, 2)
Cells(ligne, 8).Value = Cells(ligne, 3) + Cells(ligne + 1, 3)

Else
Cells(ligne, 7).Value = Cells(ligne, 2)
Cells(ligne, 8).Value = Cells(ligne, 3)
End If

Next ligne
In the first case, how I can calculate the sum for a repeated identifier by removing any occurrence of this identifier.

For example in this file, I do not want to take into account line 7 in the new table.
Thank you in advance.

2 Replies
best response confirmed by Belsam_mzh (Copper Contributor)
Solution

@Belsam_mzh It looks like you are trying to write VBA code for something that is easily done with a pivot table. But I may be mistaken.

Anyway, have a look at the pivot table I created. It seems to do what you want.

Thank you so much.
1 best response

Accepted Solutions
best response confirmed by Belsam_mzh (Copper Contributor)
Solution

@Belsam_mzh It looks like you are trying to write VBA code for something that is easily done with a pivot table. But I may be mistaken.

Anyway, have a look at the pivot table I created. It seems to do what you want.

View solution in original post