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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
| Sub requete()
Dim i As Integer, Total As Integer, j As Integer
Dim janv As Integer, fev As Integer, mars As Integer, avr As Integer, mai As Integer
Dim juin As Integer, juil As Integer, aout As Integer, sept As Integer, oct As Integer
Dim nov As Integer, dec As Integer
Dim f As Worksheet, g As Worksheet
Dim d1 As Date, d2 As Date
Dim nbremois As Integer, firstmonth As Integer, lastmonth As Integer
Set f = ThisWorkbook.Worksheets("AGO")
Set g = ThisWorkbook.Worksheets("EC_sur_1_an")
d1 = g.Cells(2, 4).Value
d2 = g.Cells(2, 6).Value
MsgBox "D1 = " & d1 & " et D2 = " & d2
'nbremois = DateDiff("m", d1, d2)
'firstmonth = Month(d1)
'''''''' Initialisation
Total = 0
janv = 0
fev = 0
mars = 0
avr = 0
mai = 0
juin = 0
juil = 0
aout = 0
sept = 0
oct = 0
nov = 0
dec = 0
nbremois = DateDiff("m", d1, d2)
firstmonth = Month(d1)
lastmonth = Month(d2)
For i = 6 To 1000
''''''''' Total
If d1 <= f.Cells(i, 3).Value And f.Cells(i, 3).Value <= d2 Then
Total = Total + 1
End If
''''''''' Janvier
If d1 <= f.Cells(i, 3) And f.Cells(i, 3).Value < d2 And Month(f.Cells(i, 3).Value) = 1 Then
janv = janv + 1
End If
If d1 <= f.Cells(i, 3) And f.Cells(i, 3).Value < d2 And Month(f.Cells(i, 3).Value) = 2 Then
fev = fev + 1
End If
If d1 <= f.Cells(i, 3) And f.Cells(i, 3).Value < d2 And Month(f.Cells(i, 3).Value) = 3 Then
mars = mars + 1
End If
If d1 <= f.Cells(i, 3) And f.Cells(i, 3).Value < d2 And Month(f.Cells(i, 3).Value) = 4 Then
avr = avr + 1
End If
If d1 <= f.Cells(i, 3) And f.Cells(i, 3).Value < d2 And Month(f.Cells(i, 3).Value) = 5 Then
mai = mai + 1
End If
If d1 <= f.Cells(i, 3) And f.Cells(i, 3).Value < d2 And Month(f.Cells(i, 3).Value) = 6 Then
juin = juin + 1
End If
If d1 <= f.Cells(i, 3) And f.Cells(i, 3).Value < d2 And Month(f.Cells(i, 3).Value) = 7 Then
juil = juil + 1
End If
If d1 <= f.Cells(i, 3) And f.Cells(i, 3).Value < d2 And Month(f.Cells(i, 3).Value) = 8 Then
aout = aout + 1
End If
If d1 <= f.Cells(i, 3) And f.Cells(i, 3).Value < d2 And Month(f.Cells(i, 3).Value) = 9 Then
sept = sept + 1
End If
If d1 <= f.Cells(i, 3) And f.Cells(i, 3).Value < d2 And Month(f.Cells(i, 3).Value) = 10 Then
oct = oct + 1
End If
If d1 <= f.Cells(i, 3) And f.Cells(i, 3).Value < d2 And Month(f.Cells(i, 3).Value) = 11 Then
nov = nov + 1
End If
If d1 <= f.Cells(i, 3) And f.Cells(i, 3).Value < d2 And Month(f.Cells(i, 3).Value) = 12 Then
dec = dec + 1
End If
Next i
g.Cells(5, 1).Value = Total
g.Cells(5, 2).Value = janv
g.Cells(5, 3).Value = fev
g.Cells(5, 4).Value = mars
g.Cells(5, 5).Value = avr
g.Cells(5, 6).Value = mai
g.Cells(5, 7).Value = juin
g.Cells(5, 8).Value = juil
g.Cells(5, 9).Value = aout
g.Cells(5, 10).Value = sept
g.Cells(5, 11).Value = oct
g.Cells(5, 12).Value = nov
g.Cells(5, 13).Value = dec
g.Activate
End Sub |
Partager