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 the 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 in cell A1, and it has returned 1 as the date is 1 January 2019.
- Back to the Excel VBA / VBA Functions