Voilà je suis en train d'écrire un code qui ferai le total de communication national et ensuit le total de communications international.
La partie national fonctionne parfaitement mais la partie international non, et je n'arrive pas à voir pourquoi.
Je crois que le problème est due au faite que j'ai besoin d'inclure plusieurs argument dans pour les communications internationales.
Voici mon code:
'Copy COST FOR NATIONAL CALLS
ActiveWorkbook.Sheets("Sheet6").Activate
Dim LastRow As Long, National As Double
Const LookupType As String = "Communications nationales"
LastRow = Cells(Rows.Count, "O").End(xlUp).Row
National = WorksheetFunction.SumIf(Range("O2:O" & LastRow), LookupType, Range("R2:R" & LastRow))
ActiveWorkbook.Sheets("SynthesisVSD").Activate
Range("C6:C7").NumberFormat = "0.00"
Range("A8").Value = "Total cost of National Communications"
Range("B8").Value = "Gross cost : "
Range("C8").Value = National
cnp = (National * 37) / 100
Range("B9").Value = "Net cost (-37%): "
Range("C9").Value = National - cnp
Range("C8:C9").Style = "Currency"
'Copy COST FOR INTERNATIONAL CALLS
TotalIN = 0
ActiveWorkbook.Sheets("Sheet6").Activate
Dim LookupType As Variant, vItem As Variant
LastRow = Cells(Rows.Count, "O").End(xlUp).Row
LookupType = Array("Communications internationales", _
"Communications effectuées a l'étranger (ROAMING)", _
"Communications recues a l'étranger (ROAMING)")
For Each vItem In LookupType
National = National + WorksheetFunction.SumIf(Range("O2:O" & LastRow), LookupType, Range("R2:R" & LastRow))
Next
ActiveWorkbook.Sheets("SynthesisVSD").Activate
Range("A4").Value = "Total cost of International Communications"
Range("B4").Value = National
Je reçois une erreur : Duplicate declaration in current scope