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
| Sub sommprod()
Dim fin_Feuil_Données As Integer
Dim fin_Feuil_Result As Integer
Dim i As Integer
Dim x As Integer
Feuil_Données = "Feuil5"
Feuil_Result = "Feuil2"
With Feuil5
fin_Feuil_Données = .Range("A65000").End(xlUp).Row
If fin_Feuil_Données = 1 Then MsgBox "Votre colonne A est vide": Exit Sub
'Suprimme les doubles items
For i = fin_Feuil_Données To 2 Step -1
For x = i - 1 To 2 Step -1
If (Cells(i, 1) = Cells(x, 1) Or Cells(x, 1) = "") Then
Cells(i, 1).EntireRow.Delete
End If
Next x
Next i
'Va chercher les montant
fin_Feuil_Result = Feuil2.Range("A65000").End(xlUp).Row
Feuil2.Columns("D:D").Clear
For i = 2 To fin_Feuil_Result
For x = 2 To fin_Feuil_Données
If Feuil2.Cells(i, 1) = Feuil5.Cells(x, 1) Then
Feuil2.Cells(i, 4).Value = Feuil2.Cells(i, 4).Value + Feuil5.Cells(x, 4).Value
'If Sheets(Feuil_Result).Cells(i, 1) = Sheets(Feuil_Données).Cells(x, 1) Then
'Sheets(Feuil_Result).Cells(i, 4).Value = Sheets(Feuil_Result).Cells(i, 4).Value + Sheets(Feuil_Données).Cells(x, 4).Value
End If
Next
Next
End With
End Sub |
Partager