VBA convert Month Number to Month Name using Excel VBA Functions. Convert or change Month Number to Name using Excel VBA ‘MonthName’ function function. It is very useful when we are dealing with date field data.
Let us see the Macro to convert Month Number to Month Name in Excel VBA. In the below macro you can change month name which is initiated to ‘iMonthNumber’ variable. Once you change month number accordingly it displays respective month name.
'Month Number to Name in Excel VBA Sub VBA_Month_Number_To_Name() 'Variable declaration Dim sMonthName As String Dim iMonthNumber As Integer iMonthNumber = 4 sMonthName = MonthName(iMonthNumber) MsgBox "Month Number : " & iMonthNumber & vbCrLf & "Month Name : " & sMonthName, vbInformation, "Month Number to Name" End Sub
output : Here is the output screen shot of above macro.
You can refer the following link for the step by step instructions.
Click on the following links of the useful resources. These helps to learn and gain more knowledge.