Return to VBA Code Examples

VBA Weekday Function

Weekday Description

Returns a number representing the day of the week, given a date value.

Simple Weekday Examples

Here is a simple Weekday example:

Sub Weekday_Example()
    MsgBox Weekday("1/1/2019")
End Sub

This code will return 3.(Because 1/1/2019 is Tuesday)

Weekday Syntax

In the VBA Editor, you can type  “Weekday(” to see the syntax for the Weekday Function:

 

The Weekday function contains 2 arguments:

Date: A Valid date (as number or string)

FirstDayOfWeek: [Optional] A constant that specifies the first day of the week. If not specified, vbSunday is assumed.

Examples of Excel VBA Weekday Function

MsgBox Weekday("1/1/2019", vbMonday)

Result: 2

MsgBox Weekday("1/1/2019", vbTuesday)

Result: 1

MsgBox Weekday("1/1/2019", vbFriday)

Result: 5

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! vba save as


Learn More!