How to use the VBA MONTH Function (Syntax + Example)

HomeVBA Functions LIST (Category Wise)How to use the VBA MONTH Function (Syntax + Example)

The VBA MONTH function is listed under the date category of VBA functions. When you use it in a VBA code, it returns the month from the date which you supplied. As you know a valid VBA date is made up of the day, month, and year so it takes a month and ignores the rest of the part. It’s just like the DAY function in the worksheet.

Syntax

Month(Date)

Arguments

  • Date: A valid date as per VBA from which you want to extract the month number.

Example

To practically understand how to use VBA MONTH function, you need to go through the below example where we have written a vba code by using it:

Sub example_MONTH()
Range("B1").Value = Month(Range("A1"))    
End Sub

In the above example, we have used MONTH to get the year from the date which we have in the cell A1 and it has returned the 1 in the result as the date is the 1-Jan-2019.

Related Functions

DATE | DATEADD | DATEDIFF | DATEPART | DATESERIAL | DATEVALUE | DAY | MONTHNAME | WEEKDAY | WEEKDAYNAME | YEAR