Bonjour,
J'ai fait une boucle qui me permet de faire une somme en fonction de 2 conditions: le nom du magasin et le mois.
J'ai un tableau de 614 lignes pour le moment.
Pour les deux premier magasin il me fait bien le total.
Mais pour les autres ils me met 0.
Voila mon code:
Avez vous une idée?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 Sub CreationTabGrafmois() Dim i As Integer, j As Integer, nommag As Variant, Total As Long Let i = 4 Let Range("I3") = "Aout" Let j = 1 For i = 4 To shtGrafAnnee.Range("E" & Rows.Count).End(xlUp).Row Step 1 Set nommag = shtGrafAnnee.Cells(i, 5) Do Let j = j + 1 If j = shtPoidsAnnee.Range("A" & Rows.Count).End(xlUp).Row And shtPoidsAnnee.Cells(j, 1) <> nommag Then Exit Do End If If shtPoidsAnnee.Cells(j, 1) = nommag And shtPoidsAnnee.Cells(j, 6) = 6 Then Total = Total + shtPoidsAnnee.Cells(j, 9) End If Loop Until shtGrafSem.Cells(j, 1) = nommag shtGrafAnnee.Cells(i, 9) = Total Let j = 1 Let Total = 0 Next i Application.CutCopyMode = False End Sub
Merci de votre aide.
Partager