我正在使用ElseIf
语句和系统日期来创建输出。
到目前为止,这是我的代码:
Dim dateToday As Date
Dim fifth As Integer
Dim fifthteenth As Integer
Dim twentyEighth As Integer
Dim thirtieth As Integer
dateToday = Today
fifth = 5
fifthteenth = 17 'this is changed to todays date for testing otherwise its 15
twentyEighth = 28
thirtieth = 30
If fifth = dateToday Then
MsgBox ("Today is the fifth")
ElseIf fifthteenth = dateToday Then
MsgBox ("Today is the fifthteenth")
ElseIf twentyEighth = dateToday Then
MsgBox ("Today is the 28th")
ElseIf thirtieth = dateToday Then
MsgBox ("Today is the 30th")
Else
MsgBox ("You do not need to do anything yet")
End If
直接到最后并生成最后一个消息框。
答案 0 :(得分:1)
Today
是工作表函数,而不是VBA函数 - 您想要Date
:
dateToday = Date
然后您实际上想要针对Day(dateToday)
而不仅仅是dateToday