Edmond
Edmond

Reputation: 149

Determine if today is Monday

How would I code an IF statement if I was trying to say

IF the date today is equal to Monday THEN

    Have Outlook prepare 3 emails

ELSE 

    Have Outlook prepare 2 emails

END IF

I just need the "IF the date today is equal to Monday."

Upvotes: 3

Views: 17674

Answers (4)

Neil Knight
Neil Knight

Reputation: 48537

Rather than using an IF statement, I would use a SELECT CASE statement instead:

Select Case Weekday(Now())    
    Case vbMonday    
      'Create 3 emails

    Case vbTuesday    
      'Create 2 emails

    Case Else       
      'Do something else

End Select

Upvotes: 3

Dirk Vollmar
Dirk Vollmar

Reputation: 176159

VBA offers you a variety of date functions. You would need the Date function to get the actual date, and the Weekday function to get the weekday from a given date.

You condition would have to look like

If Weekday(Date) = vbMonday then
    ' create email
Else
End If

Upvotes: 1

Alex K.
Alex K.

Reputation: 175758

You can:

if (Weekday(Date, vbSunday) = vbMonday) then
   ...
else
   ...
end if

Upvotes: 0

dendarii
dendarii

Reputation: 3088

If Weekday(Now()) = vbMonday Then
    MsgBox "Monday"
End If

Upvotes: 7

Related Questions