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.
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.
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.