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
| Function IsFerie(Jour As Variant) As Boolean
'Jours fériés d'après Ole P Erlandsen
'Cette fonction permet de savoir si un jour est férié, sans avoir à les gérer dans une table !!
Dim ListeFeries(1 To 11) As Long
Dim tDate As Long, an As Integer
Dim a, b, C, d, e, f, g, h, i, k, l, m, n, p As Integer
Dim Pâques As Date
tDate = CDate(Jour
an = Year(tDate)
a = Int(an Mod 19)
b = Int(an \ 100)
C = Int(an Mod 100)
d = b \ 4
e = b Mod 4
f = (b + 8) \ 25
g = (b - f + 1) \ 3
h = (19 * a + b - d - g + 15) Mod 30
i = C \ 4
k = C Mod 4
l = (32 + 2 * e + 2 * i - h - k) Mod 7
m = (a + 11 * h + 22 * l) \ 451
n = (h + l - 7 * m + 114) \ 31
p = (h + l - 7 * m + 114) Mod 31
Pâques = DateSerial(an, n, p + 1)
IsFerie = False
If tDate < 1 Then Exit Function
If an < 1900 Then Exit Function
'remplit la liste des fériés
ListeFeries(1) = CDate("1/1/" & an) 'Jour de l'An
ListeFeries(2) = DateAdd("d", 1, Pâques) 'Lundi de Pâques
ListeFeries(3) = DateAdd("d", 39, Pâques) 'Jeudi Ascension
ListeFeries(4) = DateAdd("d", 50, Pâques) 'Lundi Pentecôte
ListeFeries(5) = CDate("1/5/" & an) '1er Mai
ListeFeries(6) = CDate("8/5/" & an) '8 Mai
ListeFeries(7) = CDate("14/7/" & an) '14 Juillet
ListeFeries(8) = CDate("15/8/" & an) '15 Août
ListeFeries(9) = CDate("1/11/" & an) 'Toussaint
ListeFeries(10) = CDate("11/11/" & an) '14-18
ListeFeries(11) = CDate("25/12/" & an) 'Noël
' compare la date entrée avec la Liste des Fériés
i = 1
While i <= UBound(ListeFeries) And IsFerie = False
If tDate = ListeFeries(i) Then IsFerie = True
i = i + 1
Wend
End Function |
Partager