SOLVED

Ignore repeated identifiers

%3CLINGO-SUB%20id%3D%22lingo-sub-2623175%22%20slang%3D%22fr-FR%22%3EIgnore%20repeated%20identifiers%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2623175%22%20slang%3D%22fr-FR%22%3E%3CP%3EHello%2C%20%3CBR%20%2F%3E%20I%20created%20a%20macro%20which%20allows%20to%20compare%20the%20identifiers%20of%20two%20cells%3A%20%3CBR%20%2F%3E%20-%20if%20the%20identifiers%20are%20equal%2C%20it%20makes%20the%20sum%20of%20flow%20%3CBR%20%2F%3E%20-%20if%20not%2C%20the%20flow%20remains%20constant%3C%2FP%3E%3CP%3EFor%20line%20%3D%203%20TB%209214%20%3CBR%20%2F%3E%3CBR%20%2F%3E%20If%20Cells(line%2C%202)%20%3D%20Cells(line%20%2B%201%2C%202)%20Then%20%3CBR%20%2F%3E%20Cells(line%2C%207).Value%20%3D%20Cells(row%2C%202)%20%3CBR%20%2F%3E%20Cells(row%2C%208).Value%20%3D%20Cells(row%2C%203)%20%2B%20Cells(row%20%2B%201%2C%203)%20%3CBR%20%2F%3E%3CBR%20%2F%3E%20Else%20%3CBR%20%2F%3E%20Cells(row%2C%207).Value%20%3D%20Cells(row%2C%202)%20%3CBR%20%2F%3E%20Cells(row%2C%208).Value%20%3D%20Cells(ligne%2C%203)%20%3CBR%20%2F%3E%20End%20If%20Next%20ligne%20In%20the%20first%20%3CBR%20%2F%3E%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20case%2C%20how%20I%20can%20calculate%20the%20sum%20for%20a%20repeated%20identifier%20by%20removing%20any%20occurrence%20of%20this%20identifier.%3C%2FP%3E%3CP%3EFor%20example%20in%20this%20file%2C%20I%20do%20not%20want%20to%20take%20into%20account%20line%207%20in%20the%20new%20table.%3CBR%20%2F%3EThank%20you%20in%20advance.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2623175%22%20slang%3D%22fr-FR%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2623204%22%20slang%3D%22en-US%22%3ERe%3A%20Ignore%20repeated%20identifiers%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2623204%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1106059%22%20target%3D%22_blank%22%3E%40Belsam_mzh%3C%2FA%3E%26nbsp%3BIt%20looks%20like%20you%20are%20trying%20to%20write%20VBA%20code%20for%20something%20that%20is%20easily%20done%20with%20a%20pivot%20table.%20But%20I%20may%20be%20mistaken.%3C%2FP%3E%3CP%3EAnyway%2C%20have%20a%20look%20at%20the%20pivot%20table%20I%20created.%20It%20seems%20to%20do%20what%20you%20want.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2623225%22%20slang%3D%22fr-FR%22%3ERe%3A%20Ignore%20repeated%20identifiers%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2623225%22%20slang%3D%22fr-FR%22%3EThank%20you%20so%20much.%3C%2FLINGO-BODY%3E
Occasional 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 (Occasional 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.