There is a built in function for Weeknumber but as far as I can
remember it sometimes generates errors around the turn of the year!
For week numbers corresponding to European ISO
(Weeks Mon - Sun, First Week of Year is the first week with 4 full days)
try
Function ISOWeekNum(d1 As Date) As Integer
'Laurent Longre function
Dim Test As Long
Test = DateSerial(Year(d1), Month(d1), Day(d1))
If Test <= 0 Or Test > 401769 Then
ISOWeekNum = 0 'default error value!
Exit Function
End If
Dim d2 As Long
d2 = DateSerial(Year(d1 - Weekday(d1 - 1) + 4), 1, 3)
ISOWeekNum = Int((d1 - d2 + Weekday(d2) + 5) / 7)
End Function
but there is potentially a problem with the last dates of the year, they
will return 53, but that week won't have seven days, so, any stats based on
the week number have a high risk of being biased (such as the means that are
highly influenced by extreme values).