WeekNum Trouble
I think this function does what you want...
Function GetDate(iCalWeek As Integer) As Date
GetDate = DateSerial(Year(Now), 1, 7 * (iCalWeek - 1) + 1)
GetDate = GetDate - Weekday(GetDate) + 2
End Function
--
Rick (MVP - Excel)
"Brad" wrote in message
...
I've wrote a function to take an integer representing the Calendar Week
and
return the date of the monday of that week. A reverse of the weeknum
function. Works fine when I paste the formula in a worksheet, but I get a
compile error in vba. Here's the code.
Function GetDate(iCalWeek As Integer) As Date
'
' Takes calendar week num as an argument and returns the date of monday of
that week
'
Dim sSunday As Date
sSunday = Date(Year(Today()), 1, 1) + _
(7 - Weekday(Date(Year(Today()), 1, 1)) - 6) + (iCalWeek * 7)
GetDate = sSunday + 1
End Function
any ideas?
|