Option
Explicit
Sub
Testzeile()
Dim
x
As
Long
For
x = 23
To
33
Call
InZeile(x)
Next
x
End
Sub
Function
InZeile(Zeile
As
Long
)
Dim
Arr()
As
Variant
Dim
dtm
As
Date
Dim
kw
As
Long
, y
As
Long
Arr = Range(Range(
"J7"
), Range(
"J7"
).
End
(xlToRight)).Resize(3)
On
Error
Resume
Next
dtm = Columns(
"E"
).Cells(Zeile)
If
dtm < DateSerial(2017, 1, 1)
Or
dtm > DateSerial(2021, 12, 31)
Then
Exit
Function
If
Err.Number <> 0
Then
Exit
Function
On
Error
GoTo
0
For
y = LBound(Arr, 2)
To
UBound(Arr, 2)
If
Arr(1, y) = Year(dtm)
Then
Exit
For
Next
y
For
kw = y
To
UBound(Arr, 2)
If
Arr(3, kw) = WorksheetFunction.IsoWeekNum(dtm)
Then
Exit
For
Next
kw
With
Cells(Zeile, 9).Offset(, kw).Borders
.LineStyle = xlContinuous
.Weight = xlThick
End
With
End
Function