Last Updated on January 11, 2023 by token
1. MonthName VBA Function – Description
The MonthName VBA function returns the word name of the month from 1 to 12. It is important that the argument for this function is a number, not a date. The function can be combined with the VBA Month function . The function can also return the name of the month in an abbreviated form, eg “jul” for July. To do this, we should use the second argument of the function.
2. VBA MonthName Function – Syntax
MonthName (Month As Long, [Abbreviate As Boolean = False]) As String
Month : A number that represents the next month from 1 to 12.
Abbreviate : Optional argument. Takes the value of True or False. the default is False. If True, the month name will be returned in abbreviated three-letter form, eg “Dec” for December.
Function return: String / Word name of the month, eg “March”.
3. VBA MonthName function – Example
How to use the MonthName function in VBA Excel? Below is an example of using the MonthName function in the VisualBasic Editor.
Example 1: MonthName VBA function. The result in the MsgBox window.
MsgBox MonthName (1) MsgBox MonthName (Month (Date)) MsgBox MonthName (Month (# 5/26/2018 #)) MsgBox MonthName (Month (# 12/26/2018 #), True)
Example 2 : VBA MonthName function. The result in the worksheet cells.
Range ("A1") = MonthName (1) Range ("A2") = MonthName (Month (Date)) Range ("A3") = MonthName (Month (# 5/26/2018 #)) Range ("A4") = MonthName (Month (# 12/26/2018 #), True)
4. VB MonthName Function – Additional information
- The function does not take dates as an argument, but numbers representing successive months from 1 to 12. If we want to apply the function to a date, we should combine it with the Month VBA function .
- The second argument of the function is optional. with its help we can return the function name in abbreviated form. Eg “Jun” for June.
5. Function MonthName VisualBasic – Where to apply?
The function can be used in: Excel 2003, Excel 2007, Excel 2010, Excel 2013, Excel 2016, Excel 2019, Excel 2021, Excel 365.
The article is part of the VBA Excel function list. You can find a list of all VBA functions at this address: VBA functions .