[COLOR="DarkSlateGray"]Sub toto()
[COLOR="SeaGreen"]' Le nom du mois est en A1 ; le rang de l'année est en A2.[/COLOR]
Dim datedebut As Date, datefin As Date
Dim MoisNum As Integer, DateEnCours As Date
Dim i As Integer
MoisNum = Month("1-" & Cells(1, 1).Value & "-" & Cells(2, 1).Value)
datedebut = DateSerial(Cells(2, 1), MoisNum, 1)
datefin = DateSerial(Cells(2, 1), MoisNum + 1, 1) - 1
i = 2 [COLOR="SeaGreen"]' Utilisé pour le décalage de ligne : début en ligne i.[/COLOR]
For DateEnCours = datedebut To datefin
Cells(i, 2).Value = Day(DateEnCours) ' Colonne B.
Cells(i, 3).Value = Format(DateEnCours, "dddd") ' Colonne C.
Cells(i, 4).Value = "W-" & NOSEM(DateEnCours) & "-" & _
Weekday(DateEnCours, vbMonday) ' Colonne D.
i = i + 1
Next DateEnCours
End Sub
Function NOSEM(D As Date) As Long
[COLOR="SeaGreen"]'
' Fonction ajoutée le 14 Prairial CCXII (2/06/2004) par ROGER
' N° de la semaine dans l'année de la date D conforme à la norme ISO 8601.
'[/COLOR]
D = Int(D)
NOSEM = DateSerial(Year(D + (8 - Weekday(D, vbSunday)) Mod 7 - 3), 1, 1)
NOSEM = ((D - NOSEM - 3 + (Weekday(NOSEM, vbSunday) + 1) Mod 7)) \ 7 + 1
End Function[/COLOR]