You can do this with an array formula. In row 2, select your cell where you want the formula, paste the following into the formula bar, and press Ctrl+Shift+Enter.
=INDEX($A$1:$D$1,MIN(IF(A2:D2<0,COLUMN(A2:D2))))
For reference, A1:D1
is the range of column headers (months), and A2:D2
are the values in the row. What this formula does is look for values less than 0 and then takes the one with smallest column number. It then returns the month header in that column number.
This formula can be filled down to all rows.
EDIT:
If your data does not start at column A, you will have to make a small adjustment to the formula to get it to work. Everything stays the same in the formula except the first argument of the INDEX
function must be extended to column A. For example, if your data starts in column C, then you would use the following formula instead (entered as an array formula).
=INDEX($A$1:$F$1,MIN(IF(C2:F2<0,COLUMN(C2:F2))))
The reason for this is that the INDEX
function's second argument indicates the position in the array, not necessarily the column number. This distinction is obliterated if you just extend the array all the way to column A though (i.e., position in array will equal column number).