Have you ever wanted to convert a Month name to its serial number in Microsoft Excel, or for that matter OpenOffice.org Calc (I have just tested and it works)? For example, Converting February to 2. Unfortunately, MONTH() expects an actual date; MONTH("January"), for example, won’t convert but MONTH("14-Jan-08") will. For a report I was recently writing, I had to figure out a way to overcome this problem. Finally, I found that if a number was joined to the month name a serial number would be returned (although the text passed to month was in no way a date format recognised by Excel’s formatting).

The solution was as follows:



In cell F2 I had the month name (which was changeable due to a drop-down list). So I used =MONTH(1&F2) which returned the month’s number. If only Excel would simply accept a month also … similar to WEEKDAY() (which accepts the day and returns the day number).

So there you go, a simple way to convert the month name to the corresponding serial number in Microsoft Excel/OpenOffice.org Calc.

Share and Enjoy:
  • Twitter
  • StumbleUpon
  • Facebook
  • del.icio.us
  • Mixx
  • Propeller
  • BlinkList
  • Simpy

No related posts.