This Excel tutorial explains how to use the Excel MONTHNAME function with syntax and examples.
Description
The Microsoft Excel MONTHNAME function returns a string representing the month given a number from 1 to 12.
The MONTHNAME function is a built-in function in Excel that is categorized as a Date/Time Function. It can be used as a VBA function (VBA) in Excel. As a VBA function, you can use this function in macro code that is entered through the Microsoft Visual Basic Editor.
Syntax
The syntax for the MONTHNAME function in Microsoft Excel is:
MonthName( number, [ abbreviate ] )
Parameters or Arguments
numberA value from 1 to 12, representing the month.abbreviateOptional. This parameter accepts a boolean value, either TRUE or FALSE. If this parameter is set to TRUE, it means that the month name is abbreviated. If this parameter is set to FALSE, the month name is not abbreviated. If this parameter is omitted, it defaults to FALSE.
Returns
The MONTHNAME function returns a string value.
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
Example (as VBA Function)
The MONTHNAME function can only be used in VBA code in Microsoft Excel.
Let’s look at some Excel MONTHNAME function examples and explore how to use the MONTHNAME function in Excel VBA code:
MonthName(3) Result: 'March' MonthName(3, TRUE) Result: 'Mar' MonthName(7, FALSE) Result: 'July'
For example:
Dim LValue As String LValue = MonthName(3, TRUE)
In this example, the variable called LValue would now contain the value of ‘Mar’.