如果陈述当前date

我正在使用一个ElseIf语句和系统date来创build一个输出。

这是我的代码到目前为止:

 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 

它会直接结束并产生最后一个消息框。

Today是一个工作表函数,而不是一个VBA函数 – 你想要Date

 dateToday = Date 

那么你实际上是想testing与Day(dateToday)不只是dateToday