VBA Function: Weekday
The VBA Weekday function returns the day of the week as a number (from 1 to 7) based on a date.
Usage:
Weekday(date)
or
Weekday(date, first_day_of_week)
Numbering
By default, Sunday is considered the first day of the week (1) and Saturday is considered the last day (7).
To modify the numbering and set Monday as the first day of the week (1) and Sunday as the last day (7), add the value 2 as the second argument when using this function:
Weekday(date, 2)
Examples of Usage
Using the Weekday function to display the day of the week number for multiple dates:
Sub example()
MsgBox Weekday(#11/2/2026#) 'Returns: 2
MsgBox Weekday("11-3-26") 'Returns: 3
MsgBox Weekday("Nov 4 2026") 'Returns: 4
MsgBox Weekday("11/5/2026 17:30:21") 'Returns: 5
End Sub
Using the Weekday function to differentiate between a weekday and the weekend:
Sub example()
If Weekday(Now, 2) < 6 Then
MsgBox "It's a weekday..."
Else
MsgBox "It's the weekend!"
End If
End Sub