Function estferie(ByVal cellule As Variant) As Boolean
'Vrai si la valeur courante correspond a un jour férié
Application.Volatile
Dim Y As Long, i As Long, SylvesterDay As Date, SpecD, b As Long
Y = Year(cellule)
b = Abs((Y Mod 4 = 0 And Y Mod 100 <> 0) Or (Y Mod 400 = 0))
SylvesterDay = DateSerial(Y, 1, 1) - 1
i = EASTER(Y) - SylvesterDay - b
'Pour la France (1 Mai = 121em jour d'une année NON-bissextile)
SpecD = Array(1 - b, 121, 128, 195, 227, 305, 315, 359, i + 1, i + 39, i + 50)
Y = Int(cellule) - SylvesterDay - b
For i = 0 To UBound(SpecD)
estferie = Y = SpecD(i)
If estferie Then Exit For
Next
End Function
Function NonOuvrable(ByVal cellule As Variant) As Boolean
'Vrai si la valeur courante correspond a un jour férié
Application.Volatile
Dim Y As Long, i As Long, SylvesterDay As Date, SpecD, b As Long
NonOuvrable = False
If Weekday(cellule, vbMonday) > 5 Then ' Regarde si j'ai un samedi ou un dimanche
NonOuvrable = True
Exit Function
End If
Y = Year(cellule)
b = Abs((Y Mod 4 = 0 And Y Mod 100 <> 0) Or (Y Mod 400 = 0))
SylvesterDay = DateSerial(Y, 1, 1) - 1
i = EASTER(Y) - SylvesterDay - b
'Pour la France (1 Mai = 121em jour d'une année NON-bissextile)
SpecD = Array(1 - b, 121, 128, 195, 227, 305, 315, 359, i + 1, i + 39, i + 50)
Y = Int(cellule) - SylvesterDay - b
For i = 0 To UBound(SpecD)
NonOuvrable = Y = SpecD(i)
If NonOuvrable Then Exit For
Next
End Function
Function ProchainOuvrable(cellule As Variant) As Double
Dim d As Double
d = cellule
Application.Volatile
While NonOuvrable(d) = True ' Tant que la date est un jour non ouvrable,
d = d + 1 ' j'ajoute 1 jour
Wend
ProchainOuvrable = d ' je transmets la date trouvée
End Function
Function precedentOuvrable(cellule As Variant) As Double
Dim d As Double
d = cellule
Application.Volatile
While NonOuvrable(d) = True ' Tant que la date est un jour non ouvrable,
d = d - 1 ' j'ajoute 1 jour
Wend
precedentOuvrable = d ' je transmets la date trouvée
End Function
Function EASTER(Yr As Long) As Long
'*Dans la fonction originale, les données étaient de type Integer*
Dim Century As Long, Sunday As Long, Epact As Long, N As Long
Dim Golden As Long, LeapDayCorrection As Long, SynchWithMoon As Long
Golden = (Yr Mod 19) + 1
Century = Yr \ 100 + 1
LeapDayCorrection = 3 * Century \ 4 - 12
SynchWithMoon = (8 * Century + 5) \ 25 - 5
Sunday = 5 * Yr \ 4 - LeapDayCorrection - 10
Epact = (11 * Golden + 20 + SynchWithMoon - LeapDayCorrection) Mod 30
If Epact < 0 Then Epact = Epact + 30
If (Epact = 25 And Golden > 11) Or Epact = 24 Then Epact = Epact + 1
N = 44 - Epact
If N < 21 Then N = N + 30
N = N + 7 - ((Sunday + N) Mod 7)
EASTER = DateSerial(Yr, 3, N)
End Function