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.
Macro to Convert Month Number to Name in Excel VBA
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.
Instructions to Run VBA Macro Code or Procedure:
You can refer the following link for the step by step instructions.
Instructions to run VBA Macro Code
Other Useful Resources:
Click on the following links of the useful resources. These helps to learn and gain more knowledge.
VBA Tutorial VBA Functions List VBA Arrays VBA Text Files VBA Tables
VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers Blog