-> classeur excel qui s'appelle gege Année.
et que se classeur calcule la somme commander pour chaque produit(durant l'année). MAIS sans que lors de la création du fichier je dus taper le codes pour faire c'est calcule.
Tu fais simplement la somme d'une colonne en l'inscrivant dans une cellule;
Tu fais simplement la somme d'une colonne en l'inscrivant dans une cellule;
Range("C3").value= Application.WorksheetFunction.Sum(Range("A:A"))
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionAmandes 50 Kg
Cannelle 20 Kg
Pistache 25 Kg
Ça nous dit toujours pas ce que tu veux compter...
Tu ne peux mélanger des kilos avec des barils, soit tu comptes le tout en kilos soit en nombre de caisses barils etc.
Private Sub CommandButton1_Click() Dim i As Integer Dim Found As Boolean Dim Str As String Dim Produit() As String Dim Qté() As Integer Dim Unité() As String ReDim Produit(0) ReDim Qté(0) ReDim Unité(0) For i = 1 To ActiveWorkbook.Sheets(1).UsedRange.Rows.Count Found = False Str = Cells(i, 1).Text For a = 0 To UBound(Produit) If Str = Produit(a) Then Qté(a) = Qté(a) + Val(Cells(i, 2).Value) Unité(a) = Cells(i, 3).Text Found = True End If Next If Found = False Then ReDim Preserve Produit(UBound(Produit) + 1) ReDim Preserve Qté(UBound(Qté) + 1) ReDim Preserve Unité(UBound(Unité) + 1) Produit(UBound(Produit)) = Str Qté(UBound(Qté)) = Cells(i, 2).Value Unité(UBound(Unité)) = Cells(i, 3).Text End If Next For a = 1 To UBound(Produit) MsgBox Produit(a) & " = " & Qté(a) & " " & Unité(a) Next End Sub
Dim a, i As Integer
En suite tu reviens ici et tu m'expliques ce que t'as compris de tout ça.
Dim i As Integer Dim Found As Boolean Dim Str As String Dim Produit() As String Dim Qté() As Integer Dim Unité() As String ReDim Produit(0) ReDim Qté(0) ReDim Unité(0)
Found = False Str = Cells(i, 1).Text For a = 0 To UBound(Produit) If Str = Produit(a) Then Qté(a) = Qté(a) + Val(Cells(i, 2).Value) Unité(a) = Cells(i, 3).Text Found = True End If Next
For a=0 to UBound(Produit)
If Found = False Then ReDim Preserve Produit(UBound(Produit) + 1) ReDim Preserve Qté(UBound(Qté) + 1) ReDim Preserve Unité(UBound(Unité) + 1) Produit(UBound(Produit)) = Str Qté(UBound(Qté)) = Cells(i, 2).Value Unité(UBound(Unité)) = Cells(i, 3).Text End If
For a = 1 To UBound(Produit) MsgBox Produit(a) & " = " & Qté(a) & " " & Unité(a) Next
For a=0 to UBound(Produit)
For a= LBound(produit) to UBound(Produit)