# VBA MonthName Function

## Overview of VBA MonthName Function:

VBA MonthName function is categorized as a Date & Time function. This is a built-in Excel VBA Function. This function returns a string representing the month given a number from 1 to 12. We can use this function in VBA and can’t use in Excel. This function we use in either procedure or function in a VBA editor window in Excel. We can use this VBA MonthName Function in any number of times in any number of procedures or functions. Let us learn what is the syntax and parameters of the MonthName function, where we can use this MonthName Function and real-time examples in Excel VBA.

### Syntax of VBA MonthName Function

The syntax of the MonthName Function in VBA is

`MonthName(Month,[Abbreviate])`

The MonthName function returns a string value.

### Parameters or Arguments:

The MonthName function has two arguments in Excel VBA.
where
Month:The Month is a required argument. It represents a month value 1 to 12.
[Abbreviate]:The [Abbreviate] is an optional argument. It accepts a Boolean value either TRUE or FALSE. If ignored or omitted, it takes default value FALSE. If it is TRUE, the name of the month is abbreviated. If it is FALSE, the name of the month is not abbreviated.

### Where we can apply or use VBA MonthName Function?

We can use this MonthName Function in VBA MS Office 365, MS Excel 2016, MS Excel 2013, 2011, Excel 2010, Excel 2007, Excel 2003, Excel 2016 for Mac, Excel 2011 for Mac, Excel Online, Excel for iPhone, Excel for iPad, Excel for Android tablets and Excel for Android Mobiles.

### Example 1: Display the Month Name of Month Number(1)

Here is a simple example of the VBA DateDiff function. This below example displays the month name of month number(1).

```'Display the Month Name of Month Number(1)
Sub VBA_MonthName_Function_Ex1()

'Variable declaration
Dim sMonth As String
Dim sMntName As String

sMonth = 1

sMntName = MonthName(sMonth)

MsgBox "The Month Name of number(1) is : " & sMntName, vbInformation, "VBA MonthName Function"

End Sub
```

Output: Here is the screen shot of the first example output. ### Example 2: Display an Abbreviate Month Name of Month Number(3)

Let us see one more example of the VBA DateDiff function. This below example displays an abbreviate month name of month number(3).

```'Display an Abbreviate Month Name of Month Number(3)
Sub VBA_MonthName_Function_Ex2()

'Variable declaration
Dim sMonth As String
Dim sMntName As String

sMonth = 3

sMntName = MonthName(sMonth, True)

MsgBox "An Abbreviate month name of number(3) is : " & sMntName, vbInformation, "VBA MonthName Function"

End Sub
```

Output: Here is the screen shot of the second example output. ### Example 3: Display Non Abbreviate Month Name of Month Number(3)

Let us see another example of the VBA DateDiff function. This below example displays non abbreviate month name of month number(3).

```'Display Non Abbreviate Month Name of Month Number(3)
Sub VBA_MonthName_Function_Ex3()

'Variable declaration
Dim sMonth As String
Dim sMntName As String

sMonth = 3

sMntName = MonthName(sMonth, False)

MsgBox "Non Abbreviate month name of number(3) is : " & sMntName, vbInformation, "VBA MonthName Function"

End Sub
```

Output: Here is the screen shot of the third example output. ### Example 4: Display an Abbreviate Month Name of Specified Date

One more example of the VBA DateDiff function. This below example displays an abbreviate month name of specified date.

```
'Display an Abbreviate Month Name of Specified Date
Sub VBA_MonthName_Function_Ex4()

'Variable declaration
Dim sMonth As String
Dim sMntName As String

sMonth = "15/11/2013"

sMntName = MonthName(Month(sMonth), True)

MsgBox "An Abbreviate month name of date " & sMonth & " is : " & sMntName, vbInformation, "VBA MonthName Function"

End Sub
```

Output: Here is the screen shot of the fourth example output. ### Example 5: Display Non Abbreviate Month Name of Specified Date

One more example of the VBA DateDiff function. This below example displays non abbreviate month name of specified date.

```'Display Non Abbreviate Month Name of Specified Date
Sub VBA_MonthName_Function_Ex5()

'Variable declaration
Dim sMonth As String
Dim sMntName As String

sMonth = "15/11/2013"

sMntName = MonthName(Month(sMonth), False)

MsgBox "Non Abbreviate month name of date " & sMonth & " is : " & sMntName, vbInformation, "VBA MonthName Function"

End Sub
```

Output: Here is the screen shot of the fifth example output. ### Instructions to use Macro Codes

Here are the step by step instructions to use the VBA MonthName function in Excel VBA.

• Open an Excel workbook.
• Press Alt+F11 to open VBA Editor window.
• Go to Insert menu and click on module from the available options.
• Copy above specified procedures or macros to the VBA editor.
• Select any procedure from above codes and click on ‘Run’ command or use Keyboard shortcut ‘F5’.

#### List of VBA Functions:

Please click on below link to go back to see all List of VBA Functions.
{"ft_lang_label":"__label__en","ft_lang_prob":0.52365005,"math_prob":0.6948028,"size":5363,"snap":"2019-35-2019-39","text_gpt3_token_len":1356,"char_repetition_ratio":0.21197985,"word_repetition_ratio":0.4145786,"special_character_ratio":0.22990863,"punctuation_ratio":0.10062241,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9624618,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12],"im_url_duplicate_count":[null,1,null,2,null,2,null,2,null,2,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-08-23T08:59:37Z\",\"WARC-Record-ID\":\"<urn:uuid:b40a17e2-1314-4fb3-8601-62957bc48184>\",\"Content-Length\":\"47082\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:49c775ce-bec3-492a-83f9-f525fcc298a3>\",\"WARC-Concurrent-To\":\"<urn:uuid:64a7102e-df0e-4093-a39b-8553dabf8842>\",\"WARC-IP-Address\":\"158.106.138.15\",\"WARC-Target-URI\":\"https://vbaf1.com/functions/monthname/\",\"WARC-Payload-Digest\":\"sha1:WY3QCYLMVH66DMLPLVUM7HM43A2YJXFZ\",\"WARC-Block-Digest\":\"sha1:T6VTE4WQEWAQRJP2W5LK46DXRUWVOZNT\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-35/CC-MAIN-2019-35_segments_1566027318243.40_warc_CC-MAIN-20190823083811-20190823105811-00356.warc.gz\"}"}