Sub Test()
Agenda 2024, 5, "B3"
End Sub
Sub Agenda(an%, mois%, deb$)
Dim n%, P As Range, i%, sem%, j%
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Cells.Delete 'RAZ
Range(deb) = DateSerial(an, mois, 1)
n = DateSerial(an, mois + 1, 1) - Range(deb)
Set P = Range(deb).Resize(, n)
P.DataSeries
For i = 1 To n
P(2, i) = Application.Proper(Format(P(i), "dddd"))
P(3, i) = Format(P(i), "dd mmmm yyyy")
Next i
For i = 1 To n
sem = Application.IsoWeekNum(P(i))
For j = i + 1 To n
If Application.IsoWeekNum(P(j)) <> sem Then Exit For
Next j
P(i).Resize(, j - i).Merge 'fusionne
P(i).HorizontalAlignment = xlCenter 'centrage
P(i) = "Semaine " & Format(sem, "00")
i = j - 1
Next i
'Columns.AutoFit 'ajustement largeurs
'Cells(Rows.Count, [deb].Column).End(3).Select
End Sub