我正在运行以下表达式来比较 2 个日期的差异。如果两个日期都在单元格中,我希望它返回 0,但如果 Date2 为空白,我希望显示差异。现在,如果 date2 中没有日期,我只会得到 #ERROR。任何想法将不胜感激。
expr2: NetWorkDays([Date1],[Date2])
Option Compare Database
Public Function NetWorkdays(dteStart As Date, dteEnd As Date) As Integer
Dim intGrossDays As Integer
Dim dteCurrDate As Date
Dim i As Integer
intGrossDays = DateDiff("d", dteStart, dteEnd)
NetWorkdays = 0
For i = 0 To intGrossDays
dteCurrDate = dteStart + i
If Weekday(dteCurrDate, vbMonday) < 6 Then
End If
Next i
End Function