VBA convert Month Name to Month Number using Excel VBA Functions. Convert or change Month Name to number using VBA DateValue function and VBA Month function.
Macro to Convert Month Name to Number in Excel VBA
Let us see the Macro to convert Month Name to Month Number in Excel VBA. In the below macro you can change month name which is initiated to ‘sMonthName’ variable. Once you change month name accordingly it displays respective month number.
'VBA Month Name to Month Number Sub VBA_Month_Name_To_Number() 'Variable declaration Dim sMonthName As String Dim iMonthNumber As Integer sMonthName = "March" iMonthNumber = Month(DateValue("01-" & sMonthName & "-1900")) MsgBox "Month Name : " & sMonthName & vbCrLf & "Month Number : " & iMonthNumber, vbInformation, "Month Name to Number" End Sub
Output: Here is the output screen shot of above macro.
Watch at YouTube Channel:
you can also watch our tutorial in you tube channel.
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