totn Excel Functions

MS Excel: How to use the MONTH Function (WS, VBA)

This Excel tutorial explains how to use the Excel MONTH function with syntax and examples.

Description

The Microsoft Excel MONTH function returns the month (a number from 1 to 12) given a date value.

The MONTH function is a built-in function in Excel that is categorized as a Date/Time Function. It can be used as a worksheet function (WS) and a VBA function (VBA) in Excel. As a worksheet function, the MONTH function can be entered as part of a formula in a cell of a worksheet. As a VBA function, you can use this function in macro code that is entered through the Microsoft Visual Basic Editor.

Microsoft Excel

If you want to follow along with this tutorial, download the example spreadsheet.

Download Example

Syntax

The syntax for the MONTH function in Microsoft Excel is:

MONTH( date_value )

Parameters or Arguments

date_value
A valid date to return the month.

Returns

The MONTH function returns a numeric value between 1 and 12.

Applies To

  • Excel for Office 365, Excel 2019, Excel 2016, Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000

Type of Function

  • Worksheet function (WS)
  • VBA function (VBA)

Example (as Worksheet Function)

Let's look at some Excel MONTH function examples and explore how to use the MONTH function as a worksheet function in Microsoft Excel:

Microsoft Excel

Based on the Excel spreadsheet above, the following MONTH examples would return:

=MONTH(B2)
Result: 9

=MONTH(B3)
Result: 8

=MONTH(B4)
Result: 4

=MONTH("12/31/2011")
Result: 12

Example (as VBA Function)

The MONTH function can also be used in VBA code in Microsoft Excel.

Let's look at some Excel MONTH function examples and explore how to use the MONTH function in Excel VBA code:

Dim LMonth As Integer

LMonth = Month("12/31/2001")

In this example, the variable called LMonth would now contain the value of 12.

Frequently Asked Questions

Question: Can you help me with a formula for the following: I want cell C1 to return the value from cell B1 if cell A1 falls in January (ie: Jan 1 - Jan 31).

Answer: In cell C1, you can write your formula using the IF function and the MONTH function as follows:

=IF(MONTH(A1)=1,B1,"")

In this formula, if MONTH(A1) returns 1, then cell A1 falls in January and will return the value from B1.