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.
- Date: A valid date as per VBA from which you want to extract the month number.
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 which we have in cell A1, and it has returned the 1 in the result as the date is 1-Jan-2019.