If you know how many columns you need, or even how many columns are on the sheet, this is pretty simple. If not, and you need to look at the entire line, you may need to reconfigure the bit to avoid circular reference from the cell when the formula is part of that line.
The two second steps are pretty simple anyway - you need one of two results based on the condition, so you want to use =IF . Your condition is that the number βneedβ is less than or equal to the number βis,β and you want him to say βyesβ if this is true, and nothing if it is not. So this gives us:
=IF(need<=have,"Yes","")
The examples below assume that your table above starts with cell A1 in the upper left and that the last column in your sheet Z
Next we need to find "need" and "have." Finding "have" is pretty simple - it's just the number in column B.
Finding a βneedβ is a little more difficult. You have the right idea using INDEX and FILTER , but your formula looks a little more complicated. Basically we can use FILTER to filter out empty values, and INDEX to find the first one that is left. First, FILTER :
The range from which you want to filter is all on the same line from column D to column Z (or regardless of the final column), and the condition you want to filter is that the same cells are not empty. For the formula that you enter in cell C2, we get:
=FILTER(D2:Z2,D2:Z2<>"")
Next, INDEX : if you give an INDEX array, row number and column number, it will tell you what is in the cell where this row and column meet. Since we filter out spaces, we just want everything else to be in the first column of our filtered array, which gives us:
=INDEX(FILTER(D2:Z2,D2:Z2<>""),1,1)
Or, since we have only one row in our array, and INDEX pretty smart, just:
=INDEX(FILTER(D2:Z2,D2:Z2<>""),1)
So, to put it all together, our final formula for cell C2 is:
=IF(=INDEX(FILTER(D2:Z2,D2:Z2<>""),1)<=B2,"Yes","")
Then just drag the formula down as many lines as you need. If your sheet or is getting wider, just change Z to any of your last column.