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()
'
' test Macro
'
'
Dim i, j, mons, monsend, years, yearend, colstart, colend, nbrcolsumif, yeartest As Integer
Dim condition As Range
Dim startdate, enddate As Date
col = 14
colstart = 14
colend = 14
startdate = Sheets("Projection").Cells(1, 3) ' date de début de la periode voulue
enddate = Sheets("Projection").Cells(1, 5) ' date de fin de la periode voulue
mons = Month(startdate)
years = year(startdate)
monsend = Month(enddate)
yearend = year(enddate)
Sheets("Monthly Hours").Activate
Do While (years <> year(Sheets("Monthly Hours").Cells(4, colstart).value) Or mons <> Month(Sheets("Monthly Hours").Cells(4, colstart).value))
colstart = colstart + 1
Loop
While (yearend <> year(Sheets("Monthly Hours").Cells(4, colend).value) Or monsend <> Month(Sheets("Monthly Hours").Cells(4, colend).value))
colend = colend + 1
Wend
i = 3
j = 2
While Not IsEmpty(Sheets("Projection").Cells(2, j))
While Not IsEmpty(Sheets("Projection").Cells(i, 1))
nbrcolsumif = colend - colstart
Sheets("Projection").Cells(i, j).value = Application.WorksheetFunction.SumIfs(Sheets("Monthly Hours").Range(Cells(5, colstart), Cells(1048576, colend)), Sheets("Monthly Hours").Range(Cells(5, 4), Cells(1048576, 4 + nbrcolsumif)), Sheets("Projection").Cells(i, 1), Sheets("Monthly Hours").Range(Cells(5, 1), Cells(1048576, 1 + nbrcolsumif)), Sheets("Projection").Cells(2, j))
i = i + 1
Wend
j = j + 1
i = 3
Wend
End Sub |
Partager