The VBA MONTH Function

Description

The VBA Month Function returns the month number (from 1 to 12) of a supplied date.

The syntax of the function is:

Month( Date )

VBA Month Function Example

A simple example of the VBA Month function is shown below:

' Extract the month from the date "11/29/2015"
Const currDate = "11/29/2015"
Dim mthNum As Integer
mthNum = Month(currDate)
' The variable mthNum is now equal to 11.

After running the above VBA code, the variable mthNum holds the value 11 (November).


VBA Month Function Error

If the Month function is supplied with a value that cannot be interpreted as a valid date, it will return the error:

Run-time error '13': Type mismatch

VBA Run Time Error 13 Message Box