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
| Sub Test2()
Dim i As Integer
Dim j As Integer
Dim BU As Range, Month As Range, Scenario As Range, Brand As Range, Axe As Range, Category As Range, Scenario2 As Range, Amount As Range
Dim BUdata As Range, Monthdata As Range, Scenariodata As Range, Branddata As Range, Axedata As Range, Categorydata As Range, Scenario2data As Range
Dim Result As Double
For j = 3 To 14
For i = 8 To 21
Set Month = ActiveWorkbook.Sheets("Extract").Range("B:B")
Set BU = ActiveWorkbook.Sheets("Extract").Range("D:D")
Set Scenario = ActiveWorkbook.Sheets("Extract").Range("E:E")
Set Brand = ActiveWorkbook.Sheets("Extract").Range("H:H")
Set Axe = ActiveWorkbook.Sheets("Extract").Range("I:I")
Set Category = ActiveWorkbook.Sheets("Extract").Range("A:A")
Set Scenario2 = ActiveWorkbook.Sheets("Extract").Range("E:E")
Set Amount = ActiveWorkbook.Sheets("Extract").Range("K:K")
Set Monthdata = ActiveWorkbook.Sheets("Analysis").Cells(5, j) 'Ligne 5, colonne variable'
Set BUdata = ActiveWorkbook.Sheets("Analysis").Range("A1") 'fixe'
Set Scenariodata = ActiveWorkbook.Sheets("Analysis").Cells(6, j) 'Ligne 6, colonne variable'
Set Branddata = ActiveWorkbook.Sheets("Analysis").Cells(i, 1) 'Ligne variable, colonne A'
Set Axedata = ActiveWorkbook.Sheets("Analysis").Cells(i, 2) 'Ligne variable, colonne B'
Set Categorydata = ActiveWorkbook.Sheets("Analysis").Range("A2") 'fixe'
Set Scenario2data = ActiveWorkbook.Sheets("Analysis").Range("A4") 'fixe'
Result = WorksheetFunction.SumIfs(Amount, Month, Monthdata, BU, BUdata, Scenario, Scenariodata, Brand, Branddata, Axe, Axedata, Category, Categorydata) + WorksheetFunction.SumIfs(Amount, Month, Monthdata, BU, BUdata, Scenario, Scenario2data, Brand, Branddata, Axe, Axedata, Category, Categorydata)
Worksheets("Analysis").Cells(i, j) = Result
Next i
Next j
MsgBox ("Update done")
End Sub |
Partager