Au risque de faire monter la tensionbien vu jacky
correction car datepart(ww deconne alors evaluate
donc remplacer
par çaVB:Controls(.Tag).Caption = DatePart("ww", DateSerial(Calendar.Cbyear.Value, Calendar.Cbmonth.ListIndex + 1, A), IIf(region = 0, vbSunday, vbMonday))
VB:Controls(.Tag).Caption = Evaluate("= ISOWEEKNUM(" & CLng(DateSerial(Calendar.Cbyear.Value, Calendar.Cbmonth.ListIndex + 1, A)) & ")")
Controls(.Tag).Caption = DatePart("ww", DateSerial(Calendar.Cbyear.Value, Calendar.Cbmonth.ListIndex + 1, A) - Weekday(Date, 2) + 4, 2, 2)
Function ISOWEEK2007(dat As Date, Optional region = 1): ISOWEEK2007 = DatePart("ww", dat - Weekday(Date, IIf(region = 0, 2, 1)) + 4, 2, 2): End Function
Sub test()
MsgBox ISOWEEK2007(CDate("01/01/2021"), 0) 'EN US
MsgBox ISOWEEK2007(CDate("01/01/2021"), 1) 'EN FR
MsgBox ISOWEEK2007(CDate("01/01/2021")) 'EN FR
End Sub
Heu..!!Tiens met toi la de coté ça peut servir c'est kado
LA fonction
et pour la formule c'est pareilVB:Function ISOWEEK2007(dat As Date, Optional region = 1): ISOWEEK2007 = DatePart("ww", dat - Weekday(Date, IIf(region = 0, 2, 1)) + 4, 2, 2): End Function
pour une date en US c'est =ISOWEEK2007(A2;0)
pour une date en FR c'est =ISOWEEK2007(A2;1)
c'est beau la vie non?
Function NumSem(dDate As Date) As Integer
Dim T As Long
T = DateSerial(Year(dDate + (8 - Weekday(dDate)) Mod 7 - 3), 1, 1)
NumSem = (dDate - T - 3 + (Weekday(T) + 1) Mod 7) \ 7 + 1
End Function
Sub test()
MsgBox ISOWEEK2007US(CDate("01/01/2021"))
End Sub
Function ISOWEEK2007US(dat As Date)
Dim X&
X = CLng(dat)
ISOWEEK2007US = Evaluate("= TRUNC((" & X & "-WEEKDAY(" & X & ",2)+11-DATE(YEAR(" & X & "-WEEKDAY(" & X & " ,2)+4),1,1))/7)")
End Function
Re...
Case 1
If Weekday(DateSerial(Calendar.Cbyear, Calendar.Cbmonth.ListIndex + 1, ctrlJ.Caption), vbMonday) > 5 Then férié = RGB(200, 150, 150)
Select Case True ' Francais,French
Case dat = CDate("01/01/" & Cbyear.Value): férié = RGB(255, 200, 0): ctrlJ.ControlTipText = "Nouvel an" ' nouvel an fixe
Case dat = CDate("01/05/" & Cbyear.Value): férié = RGB(255, 200, 0): ctrlJ.ControlTipText = "fête du travail" ' fete du travail fixe
Case dat = paques: férié = RGB(255, 200, 0): ctrlJ.ControlTipText = "Pâques" ' paques ok calculée
Case dat = paques + 39: férié = RGB(255, 200, 0): ctrlJ.ControlTipText = "Ascension" ' ascension calculée
Case dat = paques + 49: férié = RGB(255, 200, 0): ctrlJ.ControlTipText = "Pentecôte" ' pentecote calculée
Case dat = paques + 50: férié = RGB(255, 200, 0): ctrlJ.ControlTipText = "Lundi de Pentecote" ' pentecote calculée
Case dat = CDate("08/05/" & Cbyear.Value): férié = RGB(255, 200, 0): ctrlJ.ControlTipText = "Fête de la victoire 1945" ' Victoire 1945 fixe
Case dat = CDate("14/07/" & Cbyear.Value): férié = RGB(255, 200, 0): ctrlJ.ControlTipText = "Fête Nationale" ' fete nationale fixe
Case dat = CDate("15/08/" & Cbyear.Value): férié = RGB(255, 200, 0): ctrlJ.ControlTipText = "Assomption" ' Assomption fixe
Case dat = CDate("01/11/" & Cbyear.Value): férié = RGB(255, 200, 0): ctrlJ.ControlTipText = "Toussaint" ' Toussaint fixe
Case dat = CDate("11/11/" & Cbyear.Value): férié = RGB(255, 200, 0): ctrlJ.ControlTipText = "Armistice 1918" ' Armistice 1918 fixe
Case dat = CDate("25/12/" & Cbyear.Value): férié = RGB(255, 200, 0): ctrlJ.ControlTipText = "NOEL" ' noel fixe
Case dat = paques + 2: férié = RGB(255, 230, 0): ctrlJ.ControlTipText = "(Alsace)Vendredi saint" ' (Alsace)Vendredi saint" calculée
Case dat = CDate("26/12/" & Cbyear.Value): férié = RGB(255, 200, 0): ctrlJ.ControlTipText = "(Alsace) Saint Etienne" ' (Alsace) Saint Etienne fixe"