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 35 36 37 38 39 40 41
| Sub Testtt()
Application.ScreenUpdating = False 'juste pour arrêter affichage écran et améliorer le temps d'exécution du macro
'************************************************************************************************************************
Dim unique As New Collection
Dim i As Integer
On Error Resume Next
For Each Cel In Range("E1:E" & [E65000].End(xlUp).Row)
If Cells(Cel.Row, 5) <> "" Then
unique.Add Cel.Value, CStr(Cel.Value)
End If
Next Cel
With Sheets("feuil2")
.Activate
On Error GoTo 0
For i = 1 To unique.Count
.Cells(i, 5) = unique(i)
Next i
dernligne = .Range("E" & Rows.Count).End(xlUp).Row
TABLO = Sheets("feuil1").Range("A1", "F" & Sheets("feuil1").Range("F" & Sheets("feuil1").Rows.Count).End(xlUp).Row)
Dim somme As Variant
For j = 1 To dernligne
somme = 0
For i = LBound(TABLO, 1) To UBound(TABLO, 1)
If .Cells(j, 5) = TABLO(i, 5) Then
somme = somme + TABLO(i, 6)
.Cells(j, 6) = somme
.Cells(j, 1) = TABLO(i, 1)
.Cells(j, 2) = TABLO(i, 2)
.Cells(j, 3) = TABLO(i, 3)
.Cells(j, 4) = TABLO(i, 4)
End If
Next i
Next j
End With
Sheets("feuil2").Select
MsgBox ("Regroupement effectué avec succès .... ")
Application.ScreenUpdating = True
End Sub |
Partager