Bython
Bython

Reputation: 1145

Inverse of the MonthName() - Function?

I've got a month number. By typing in the immediate editor MonthName(11,True) I get the result NOV. What would be the inverse of this function? e.g. I've got SEP and I want by typing function(SEP) the number 9 as an Output

Upvotes: 0

Views: 3515

Answers (1)

Rahul Tripathi
Rahul Tripathi

Reputation: 172618

You are looking for this:

Sub Sample()
    Dim MonthNm As String
    MonthNm = "September"
    Debug.Print Month(DateValue("01 " & MonthNm & " 2014"))
End Sub

or in small:

=MONTH(DATEVALUE(A1&"9"))

Also check How to convert month name to number in Excel?

Upvotes: 3

Related Questions