Function DateOfWeek(ByVal Yearf As Integer, ByVal Weekf As Integer, Optional ByVal Dayf As Integer = 1, Optional ByVal FirstDayOfWeek As Integer = 0)
On Error GoTo ext
Dim fd As Date, fw%
fd = DateValue(Yearf & "-1-1")
fw = Weekday(fd)
FirstDayOfWeek = FirstDayOfWeek Mod 7
DateOfWeek = fd + 7 * (Weekf - 1) + Dayf - IIf(Weekf = 1, 1, fw - FirstDayOfWeek)
Exit Function
ext:
DateOfWeek = "#N/A"
End Function