Het gaat om alle weken van het jaar en dan maandag tot vrijdag.
in Tablad 1 week 1 tablad 2 week 2 enzovoort
...om in elk tablad de juiste week te hebben staan gecopieerd kwa lay out maar veranderend van data
Voor 2024 kun je onderstaande macro gebruiken, waarbij wordt begonnen met week 1 in blad1.
Sub weken2024()
Dim jr As Integer, m As Integer, mydate As Date
Dim sc As Integer, wk As Integer, x As Integer, y As Integer
Application.DisplayAlerts = False
Application.ScreenUpdating = False
sc = ThisWorkbook.Sheets.Count
If sc > 1 Then
For x = sc To 2 Step -1
Sheets(x).Delete
Next x
End If
With Sheets(1)
.Cells.ClearContents
jr = 2024: m = 1: wk = 1
.Name = "2024-wk " & wk
For x = 1 To 3
.Cells(1, x) = Application.Choose(x, 2024, "Week", wk)
Next x
For x = 1 To 7
.Cells(2, x) = Application.Choose(x, "Maandag", "Dinsdag", _
"Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag")
.Cells(3, x) = jr & "-" & m & "-" & x
Next x
mydate = .Cells(3, 7).Value
With .Range("a1:g3")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Columns.AutoFit
End With
.Range("a1:g2").Font.Bold = True
End With
Application.DisplayAlerts = True
Do Until wk > 52
Sheets(wk).Copy After:=Sheets(wk)
With Sheets(wk + 1)
.Name = "2024-wk " & wk + 1
.Cells(1, 3).Value = wk + 1
For y = 1 To 7
mydate = mydate + 1
.Cells(3, y) = mydate
Next y
End With
wk = wk + 1
If wk = 53 Then
Cells(1, 1) = 2025: Cells(1, 3) = 1
Sheets(Sheets.Count).Name = "2025-wk 1"
End If
Loop
Sheets(1).Activate
ActiveWindow.TabRatio = 0.9
Application.ScreenUpdating = True
End Sub