Re : calendrier jours ouvrés sans weekend
Staple, concernant le #33,
Sub CalendrierIII()
Dim calend As Range, i&
Application.ScreenUpdating = False
If IsEmpty([A7]) Then [A7] = Now '"1/1/" & Year(Now)
Set calend = Range("A7:A372") 'soit 366 jours (cas des années bissextiles)
Range("A7").AutoFill Destination:=[calend], Type:=
xlFillWeekdays 'xlFillDays
calend.NumberFormat = "ddd d/mm/yyyy"
For i = Range("A65536").End(xlUp).Row To 7 Step -1
If EstFerie(Cells(i, "A")) Then
'Or estWE(Cells(i, "A"))
Cells(i, "a").Delete shift:=xlUp
End If
Next i
End Sub
Function EstFerie(D) As Boolean
'd'après Alain Vallon, mpfe
Dim A&, M As Byte
A = Year(D): M = Month(D) ' variables date jour
jf1 = DateValue("1/1/" & A) * 1 'Jour de l'A
If D = jf1 Then GoTo Fin
jf2 = Evaluate("round(date(" & A & ",4,mod(234-11*mod(" & _
A & ",19),30))/7,)*7-6") + 1 'Lundi Pâques
If D = jf2 Then GoTo Fin
jf3 = DateValue("1/5/" & A) * 1 ' 1° Mai
If D = jf3 Then GoTo Fin
jf4 = DateValue("8/5/" & A) * 1 ' 8 Mai
If D = jf4 Then GoTo Fin
jf5 = jf2 + 38 * 1 ' Jeudi Ascension
If D = jf5 Then GoTo Fin
jf6 = jf2 + 49 * 1 ' Lundi Pentecôte
If D = jf6 Then GoTo Fin
jf7 = DateValue("14/7/" & A) * 1 ' 14 Juillet
If D = jf7 Then GoTo Fin
jf8 = DateValue("15/8/" & A) * 1 ' 15 Aout
If D = jf8 Then GoTo Fin
jf9 = DateValue("1/11/" & A) * 1 ' Toussaint
If D = jf9 Then GoTo Fin
jf10 = DateValue("11/11/" & A) * 1 ' 11 Novembre
If D = jf10 Then GoTo Fin
jf11 = DateValue("25/12/" & A) * 1 ' Noël
If D = jf11 Then GoTo Fin
jf12 = DateValue("26/12/" & A) * 1 ' 26 décembre
If D = jf12 Then GoTo Fin
jf13 = jf2 - 3 * 1 ' vendredi saint
If D = jf13 Then GoTo Fin
Exit Function
Fin:
EstFerie = True
End Function
du coup
'Function estWE(D) As Boolean
'estWE = (Weekday(D, vbMonday) > 5)
'End Function
devient inutile (dommage, c'était fun cette fonction)
Sub Macro()
'1er cas
Selection.AutoFill Destination:=Range("A7:A10"), Type:=xlFillWeekdays
'2ème cas
Selection.DataSeries Rowcol:=xlColumns, Type:=xlChronological, Date:= _
xlWeekday, Step:=1, Trend:=False
End Sub
C'est intéressant cette différence de syntaxe, pour un même résultat...
Biz
C@thy