Excel MONTH Function
The Excel MONTH function returns the month from a specified date
Example: Excel MONTH Function
=MONTH("15/03/2017")
|
Result in cell C5 (3) - in this example we are inserting the date directly into the Excel MONTH function, which returns the month component of the date.
|
METHOD 2. Excel MONTH Function using links
EXCEL
=MONTH(B5)
|
Result in cell C5 (3) - in this example we are referencing to a cell that contains a date and the Excel MONTH function returns the month component of the date.
|
METHOD 3. Excel MONTH function using the Excel built-in function library with hardcoded values
EXCEL
Formulas tab > Function Library group > Date & Time > MONTH > populate the input box
=MONTH("15/03/2017") Note: in this example we are manually populating the input box with the date from which we want to return the month component. If entering the date directly into the input box, as per this example, we need to use the double quotation marks. |
METHOD 4. Excel MONTH function using the Excel built-in function library with links
EXCEL
Formulas tab > Function Library group > Date & Time > MONTH > populate the input box
=MONTH(B5) Note: in this example we are populating the input box with a cell reference that captures the date from which we want to return the month component. |
Sub Excel_MONTH_Function_Using_Hardcoded_Values()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("MONTH")
'apply the Excel MONTH function
ws.Range("C5") = Month("15/03/2017")
ws.Range("C5") = Month("15/03/2017")
End Sub
OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named MONTH.
Worksheet Name: Have a worksheet named MONTH.
ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("C5") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.
METHOD 2. Excel MONTH function using VBA with links
VBA
Sub Excel_MONTH_Function_Using_Links()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("MONTH")
'apply the Excel MONTH function
ws.Range("C5") = Month(ws.Range("B5"))
ws.Range("C5") = Month(ws.Range("B5"))
End Sub
OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named MONTH.
Date: If using this exact VBA code, which sources the date from cell ("B5"), you will need to capture the date from which you want to extract the month in cell ("B5").
Worksheet Name: Have a worksheet named MONTH.
Date: If using this exact VBA code, which sources the date from cell ("B5"), you will need to capture the date from which you want to extract the month in cell ("B5").
ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("C5") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.
Date: Select the date from which you want to extract the month by changing the cell reference ("B5") to any cell in the worksheet that contains the date and doesn't conflict with the formula.