Bonsoir
J'ai besoin de votre aide pour corriger une macro.
Je pars d'une balance comptable comportant des montants en positif et des montant en négatif, qui doivent être recopier dans des onglets de destination selon une table d'affectation.
Elle fonctionne correctement sauf qu'elle me renvoie des montant négatif, alors que pour un but de présentation je les voudrais en valeur absolue uniquement pour certain compte.
voici mon code
Merci de votre aide
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 Private Sub Fill() Dim r As Range Dim NbLignesBalance As Long Dim NbLignesConfig As Long Dim ListePlageComptes As New objListePlageDeComptes Dim PlageCompte As objPlageDeComptes Dim value As Double Dim SommeProd As Variant NbLignesBalance = frmBalance.[A1].CurrentRegion.Rows.Count NbLignesConfig = frmConfig.[A1].CurrentRegion.Rows.Count On Error Resume Next For Each r In frmConfig.Range("A2:A" & NbLignesConfig) ListePlageComptes.Clear ListePlageComptes.Init (r.Offset(0, 2).value) value = 0 For Each PlageCompte In ListePlageComptes.Liste SommeProd = Evaluate(PlageCompte.Signe & "SUMPRODUCT((Balance!G2:G" & NbLignesBalance & ">=" & PlageCompte.Debut & ")*(Balance!G2:G" & NbLignesBalance & "<=" & PlageCompte.Fin & ")*Balance!E2:E" & NbLignesBalance & ")") SommeProd = Evaluate("SUMPRODUCT((Balance!G2:G" & NbLignesBalance & ">=" & PlageCompte.Debut & ")*(Balance!G2:G" & NbLignesBalance & "<=" & PlageCompte.Fin & ")*Balance!E2:E" & NbLignesBalance & ")") If IsNumeric(SommeProd) Then value = value + SommeProd Next PlageCompte ThisWorkbook.Worksheets(r.value).Range(r.Offset(0, 1).value) = value Next r On Error GoTo 0 End Sub
Christian
Partager