essaie sa ;-)
Public Function NbOuvrés&(D1, D2)
Dim Prem As Date, Der As Date, i As Date
If D1 = D2 Then Prem = D1 If TYPEJOUR(Prem) = 0 Then NbOuvrés = 1 Exit Function End If Prem = D1 Der = D2 For i = Prem To Der NbOuvrés = NbOuvrés + (TYPEJOUR(i) = 0) * -1 Next i End Function
'Cette fonction renvoie 0 si le jour passé en paramètre est un jour de semaine, '1 s'il s'agit d'un samedi ou d'un dimanche et 2 s'il s'agit d'un jour férié. 'Valide jusqu'en 2099 et pour les jours fériés français
Public Function TYPEJOUR(D As Date)
'L. Longre Dim A As Integer, t As Integer Dim LP As Date, LD As Long Dim Toto As Long
A = Year(D) If A > 2099 Then TYPEJOUR = 0 Exit Function End If LD = Int(D) If LD <= 2 Then If LD = 1 Then TYPEJOUR = 2 Exit Function End If End If t = (((255 - 11 * (A Mod 19)) - 21) Mod 30) + 21 LP = DateSerial(A, 3, 2) + t + (t > 48) _ + 6 - ((A + A \ 4 + t + (t > 48) + 1) Mod 7) Select Case D ' Jours fériés mobiles Case Is = LP, Is = LP + 38, Is = LP + 49 TYPEJOUR = 2 ' Jours fériés fixes Case Is = DateSerial(A, 1, 1), Is = DateSerial(A, 5, 1), _ Is = DateSerial(A, 5, 8), Is = DateSerial(A, 7, 14), _ Is = DateSerial(A, 8, 15), Is = DateSerial(A, 11, 1), _ Is = DateSerial(A, 11, 11), Is = DateSerial(A, 12, 25) TYPEJOUR = 2 Case Else ' Samedi ou dimanche If Weekday(D, vbMonday) >= 6 Then TYPEJOUR = 1 End If End Select
End Function
' utilistation de la fonction
NbOuvrés& (date_début, date_fin)
|