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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
| Sub Jours_Feries()
Dim JFeries(11) As Long
Dim Nb, Epacte, i, j, k, tmp, nbjouran, o As Long
Dim PLune As Date, LPaques, v, firstDay, lastDay, q, Val, www As Date
Dim An, r As Integer
Dim Plage, Cell, PlageZ, Cellw As Range
Dim p As Variant
' Valeur de l'année pour remplir le tableau
An = Application.InputBox("Entrez l'année")
' Calcul du Lundi de Pâques
Nb = (An Mod 19) + 1
' Différence entre calendrier solaire et lunaire
Epacte = (11 * Nb - (3 + Int(2 + Int(An / 100)) * 3 / 7)) Mod 30
PLune = DateSerial(An, 4, 19) - ((Epacte + 6) Mod 30)
If Epacte = 24 Then PLune = PLune - 1
' Valable entre 1900 et 2199 : on verra bien ?
If Epacte = 25 And (An >= 1900 And An < 2200) Then PLune = PLune - 1
' Lundi de Pâques
LPaques = PLune - Weekday(PLune) + vbMonday + 7
Erase JFeries
' Jour de l'An
JFeries(1) = DateSerial(An, 1, 1)
' Paques
JFeries(2) = LPaques
' Ascension
JFeries(3) = LPaques + 38
' Pentecôte
JFeries(4) = LPaques + 49
' Fete du travail
JFeries(5) = DateSerial(An, 5, 1)
' Anniversire 1945
JFeries(6) = DateSerial(An, 5, 8)
' Fete Nationale
JFeries(7) = DateSerial(An, 7, 14)
' Assomption
JFeries(8) = DateSerial(An, 8, 15)
' Toussaint
JFeries(9) = DateSerial(An, 11, 1)
' Armistice 1918
JFeries(10) = DateSerial(An, 11, 11)
' Noel
JFeries(11) = DateSerial(An, 12, 25)
' Tri Tableau JFeries()
For i = LBound(JFeries) To UBound(JFeries)
j = i
For k = j + 1 To UBound(JFeries)
If JFeries(k) <= JFeries(j) Then j = k
Next k
If i <> j Then
tmp = JFeries(j)
JFeries(j) = JFeries(i)
JFeries(i) = tmp
End If
Next i
Set Plage = Range("A1:A11")
i = 1
For Each Cell In Plage
Cell.Value = JFeries(i)
i = i + 1
Next
firstDay = "1/1/" & An
lastDay = "31/12/" & An
nbjouran = DateDiff("d", firstDay, lastDay) + 1
Dim montab() As Variant
ReDim montab(nbjouran) As Variant
firstDay = CDate(firstDay) - 1
For r = 1 To nbjouran
montab(r) = CDate(firstDay) + 1
firstDay = CDate(firstDay) + 1
Debug.Print (firstDay)
Next r
p = "C1:c" & nbjouran
Set PlageZ = Range(p)
o = 1
For Each Cellw In PlageZ
Cellw.Value = montab(o) + 1
o = o + 1
Next
Dim aa, xx, pp As Variant
aa = montab
xx = "08/01/1944"
pp = Application.Match(xx, aa, 0)
Dim Rep As Boolean
For i = LBound(montab) To UBound(montab)
Val = montab(i)
Cells(i, 5).Select
Cells(i, 5).Value = Val
Rep = Application.Match(CLng(Val), JFeries, 1)
If Rep = True Then
ActiveCell.Interior.Color = RGB(174, 240, 194)
Else
ActiveCell.Interior.Color = RGB(255, 255, 255)
End If
Next
End Sub |
Partager