3

I have a table with month headers at the top:

January | February | March | ...

Is there a way with one formula that I can get a list of month numbers?

January | February | March | ...
--------+----------+-------+----
      1 |        2 |     3 | ...

I saw this answer about turning a month string into a month number with =MONTH(DATEVALUE(A1 & " 1")) but when I tried to do =ARRAYVALUE(MONTH(DATEVALUE(A1:1 & " 1"))) it didn't work. In fact MONTH(DATEVALUE(A1:1 & " 1")) gives the same result as MONTH(DATEVALUE(A1 & " 1")).

3

There is no arrayvalue command; there is arrayformula.

Yes, MONTH(DATEVALUE(A1:1 & " 1")) gives the same result as MONTH(DATEVALUE(A1 & " 1")) because without arrayformula, it expects one value as an argument. Given more, it only takes the first one.

The correct formula (tested in my spreadsheet) is

 =ARRAYFORMULA(MONTH(DATEVALUE(A1:1 & " 1")))
2
  • Oh whoops. I meant ARRAYFORMULA. I just tried it in a new sheet and it worked, but it's not working in a different sheet I have. There must be some sort of collision happening. – Robert Hickman Jan 9 '16 at 21:38
  • 1
    Sometimes the data present in the sheet prevent the output of arrayformula from expanding. Also, consider whether you really need A1:1 - presumably there are just 12 months, so A1: L1 would be enough. – user79865 Jan 9 '16 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.