Bonjour à tous je suis très embêté car je ne savais pas que quand tu insère un bouton pour lancer ta macro, elle reconnait pas les "With" donc du coup j'ai du les enlever et ma macro ne marche plus comme elle devrait... C'est à dire elle me faire tous bien sauf cette étape là : 'MONTANT TOTAL NON RECOUVRE SUR DOSSIER => COLONNE R
Voici le codage qui marche avec le With :
Voici la ligne qui me donne pas le résultat indiquer
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 Sub Test() With Sheets("SUIVTRANS EN COURS") Derligne = .Range("A" & Rows.Count).End(xlUp).Row .Range("M2:M" & Derligne).ClearContents Tablo = .Range("J2", "K" & .Range("K" & .Rows.Count).End(xlUp).Row) For j = 2 To Derligne somme = 0 codeP = .Cells(j, "H") For i = LBound(Tablo, 1) To UBound(Tablo, 1) If .Cells(j, "J") = Tablo(i, 1) Then If .Cells(i + 1, "H") <> codeP Then GoTo pasDeCommentaire Else somme = somme + CDbl(Tablo(i, 2)) End If End If Next i 'MONTANT TOTAL NON RECOUVRE SUR DOSSIER => COLONNE R .Cells(j, 18) = somme 'REGULARISATION ECART-TEMPLATE (2) If Cells(j, "R") >= -10 And Cells(j, "R") <= 10 And Cells(j, "R") <> 0 Then .Cells(j, 13) = "REGULARISATION ECART-TEMPLATE" 'SOLDE CREDITEUR - A REMBOURSER (3) ElseIf Cells(j, "R") < -10 Then .Cells(j, 13) = "SOLDE CREDITEUR - A REMBOURSER" 'REGLT CIE - SOLDE DEBITEUR (4) ElseIf .Cells(j, 9) = "REGLT" And Cells(j, "R") > 10 Then .Cells(j, 13) = "REGLT CIE-SOLDE-DEBITEUR" 'ANNULATION TECHNIQUE (5) ElseIf Mid(.Cells(j, "F").Text, 5, 1) = "A" And Mid(.Cells(j, "F").Text, 1, 1) = "S" Then .Cells(j, "M").Value = "ANNULATION TECHNIQUE" End If pasDeCommentaire: Next j End With End SubVoici LE CODE sans le With :
Code : Sélectionner tout - Visualiser dans une fenêtre à part .Cells(j, 18) = somme
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 Sub testsia() Sheets("SUIVTRANS EN COURS").Activate Derligne = Range("A" & Rows.Count).End(xlUp).Row Range("R3:R" & Derligne).ClearContents Tablo = Range("J3", "K" & Range("K" & Rows.Count).End(xlUp).Row) For j = 3 To Derligne somme = 0 codeP = Cells(j, "H") For i = LBound(Tablo, 1) To UBound(Tablo, 1) If Cells(j, "J") = Tablo(i, 1) Then If Cells(i + 1, "H") <> codeP Then Else somme = somme + CDbl(Tablo(i, 2)) End If End If Next i 'MONTANT TOTAL NON RECOUVRE SUR DOSSIER => COLONNE R Cells(j, 18) = somme 'REGULARISATION ECART-TEMPLATE (2) If Cells(j, "R") >= -10 And Cells(j, "R") <= 10 And Cells(j, "R") <> 0 Then Cells(j, 13) = "REGULARISATION ECART-TEMPLATE" 'SOLDE CREDITEUR - A REMBOURSER (3) ElseIf Cells(j, "R") < -10 Then Cells(j, 13) = "SOLDE CREDITEUR - A REMBOURSER" 'REGLT CIE - SOLDE DEBITEUR (4) ElseIf Cells(j, 9) = "REGLT" And Cells(j, "R") > 10 Then 'Cells(j, 13) = "REGLT CIE-SOLDE-DEBITEUR" 'ANNULATION TECHNIQUE (5) ElseIf Mid(Cells(j, "F").Text, 5, 1) = "A" And Mid(Cells(j, "F").Text, 1, 1) = "S" Then Cells(j, "M").Value = "ANNULATION TECHNIQUE" End If pasDeCommentaire: Next j End Sub
Partager