Function WeekFistDateInYear(ByVal lngWeek As Long, _ ByVal dteA As Date, _ Optional ByVal bteFirstDay As Byte) As Date '本函数获取某年的第N周的第一天 '其实可以直接合并为一个公式,无需另外写公式
Dim dte As Date dte = DateAdd("ww", lngWeek, dteA) WeekFistDateInYear = DateAdd("d", 7 - Weekday(dte, bteFirstDay), dte) End Function Function test() Dim dte1 As Date Dim dte2 As Date dte1 = #1/1/2006# Debug.Print WeekFistDateInYear(40, dte1, vbMonday) dte2 = WeekFistDateInYear(40, dte1, vbMonday) Debug.Print Weekday(dte2) '以下用 DatePart 函数验证该日期是否正确 Debug.Print DatePart("ww", dte2, vbMonday, vbFirstFullWeek) End Function