返回列表 上一主題 發帖

再次請問一下....

每月第二個禮拜一,我是用算的,提供給您參考。

Sub nn()

Dim startdate As Date
Dim temp As Date

startdate = "2010/1/1"
currentmonth = 1
startcell = 1

Dim firstMonday As Boolean
firstMonday = False

For i = 0 To 365

temp = startdate + i

If currentmonth <> Month(temp) Then
GoTo forend
End If

If Weekday(temp, vbMonday) = 1 Then
    If firstMonday = False Then
    firstMonday = True
    GoTo forend
    End If

    Cells(startcell, 1) = temp
    startcell = startcell + 1
    firstMonday = False
    currentmonth = currentmonth + 1
End If

forend:
Next

End Sub

TOP

        靜思自在 : 對父母要知恩,感恩、報恩。
返回列表 上一主題