VBA – Convert Month Name to Number and Vice Versa

Convert number to name – [3 -> March]

Converting month number to name in VBA is actually coming out of the box with the MonthName() function, which is built-in the stanard VBA  library:

The result is not flabbergasting, but expected:

Convert name to number – [March -> 3]

MonthName()  is a built in function in VBA, but MonthNumber() does not exist. Unfortunately. That’s why we should write it:

And it works even a bit better than expected, accepting both “Feb” and “February” as an input:


Tagged with: , , , , ,