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
| '****************************************************************************************
'Function nbjmois
'Cette fonction détermine le nombre de jours dans un mois
'***************************************************************************************
Public Function nbjmois(ByVal ma As Date) As Integer
Dim ms As Date
If Month(ma) = 12 Then
nbjmois = 31
Else
ms = CDate("01/" & Month(ma) + 1 & "/" & Year(ma)) 'la date du premier jour du mois suivant
nbjmois = Day(DateAdd("D", -1, ms)) 'retrancher 1 jour et récuperer le jour
End If
End Function
'************************************************************************************
Sub Calendrier()
With Union(Rows(12), Rows(16), Rows(20), Rows(24), Rows(28))
.NumberFormat = "[$-40C]dd-mmm;@"
End With
Mois = Month(Date)
Année = Year(Date)
PreJour = Weekday("01/" & Mois & "/" & Year(Date), vbMonday)
Finmois = Day(DateSerial(Année, Mois, 1 - 1))
DebMois = Day(DateSerial(Année, Mois + 32, 1 - 1))
NumJour = Mois & "/01/" & Année
Select Case PreJour
Case Is = 1
Range("D12") = NumJour
ColDeb = 4
Case Is = 2
Range("E12") = NumJour
ColDeb = 5
Case Is = 3
Range("F12") = NumJour
ColDeb = 6
Case Is = 4
Range("G12") = NumJour
ColDeb = 7
Case Is = 5
Range("H12") = NumJour
ColDeb = 8
Case Is = 6
Range("I12") = NumJour
ColDeb = 9
Case Is = 7
Range("J12") = NumJour
ColDeb = 10
End Select
dtedate = "01/" & Mois & "/" & Année 'variable qui contient la date actuelle et commence au premier jour du mois
dtefin = Finmois & "/" & Mois - 1 & "/" & Année
LigFin = 32
LigDeb = 12
ColFin = 10
For col = ColDeb To ColFin
Cells(LigDeb, col).Value = DateAdd("D", i, dtedate)
i = i + 1
Next
Caldeb = 4
For col = Caldeb To ColDeb - 1
Cells(LigDeb, col).Value = DateAdd("D", i - 1, dtefin)
i = i - 1
Next
For lig = LigDeb + 4 To LigFin
For col = Caldeb To ColFin
Cells(lig, col).Value = DateAdd("D", i, dtedate)
i = i + 1
Next
lig = lig + 3
Next
End Sub |
Partager