請教跳過周六周日兩天不算此程序如何改?
sub test()
Dim rng
For Each rng In Range("AE4:AE15")
If rng <> "" And Month(rng) = Month(Date) And Year(rng) = Year(Date) Then
If Day(Date) - Day(rng) < 4 And Day(Date) - Day(rng) >= 0 Then '前三天到當日
MsgBox Day(Date) - Day(rng)
End If
End If
Next
end sub作者: t8899 時間: 2014-10-25 21:52
本帖最後由 t8899 於 2014-10-25 22:17 編輯
想了一個小時 :-(
Sub MA3333()
Dim rng, k, abc, date2
For Each rng In Range("AE4:AE15")
If rng <> "" And Month(rng) = Month(Date) And Year(rng) = Year(Date) Then
'------------------------------abc求出周六周日共幾天
abc = 0
date2 = Date
date2 = date2 - 1
For k = 1 To rng - date2
date2 = date2 + 1
If Weekday(date2) = 1 Or Weekday(date2) = 7 Then abc = abc + 1
Next
'-----------------------------abc求出周六周日共幾天
If Day(rng) - Day(Date) - abc < 4 And Day(rng) - Day(Date) >= 0 Then '前三天到當日通知
MsgBox "前 " & Day(rng) - Day(Date)& " 天通知
End If
End If
'-----
Next
End Sub作者: GBKEE 時間: 2014-10-26 09:04