Return to VBA Code Examples

VBA Day Function

Day Description

Returns the day of the month (a number from 1 to 31) given a date value.

Simple Day Examples

Here is a simple Day example:

Sub Day_Example()
    MsgBox Day(#8/15/2019#)
End Sub

This will return 15.

Day Syntax

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

The Day function contains an argument:

Date: A valid date.

Examples of Excel VBA Day Function

MsgBox Day(#10/12/2019#)

Result: 12

MsgBox Day("7/15/2019")

Result: 15

MsgBox Day(Date)

Result will be the day of the current system date.

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!