Hi jack,
The problem is only of refrence. I will try to explain my method so that in future you can change the formula as your need.
In sheet I had use four formula.
1. Helper column formula in cell H5 (Normal formula), This is use to identify row containing the number to be searched say 36. Copy this formula till the data end. I had use below formula (RANK() function, but we can also use any other function such as MATCH() to identify row with the number.
Formula :--> =RANK($F$2,B5:G5)....$F$2 contains the number to be searched say 36 and B5:G5 is relative array of that row.
2. In cell J2 I had count total number of above rows which contain a number. This is again a normal formula, this is use to turn our main formula ON and OFF. Change the refrence if you increase the row. You will get twice the result of this number. So you had to copy the next two main formula twice the row of this number.
=COUNT($H$5:$H$278)
3. In cell K5, I had below formula to get row of data above the row in which the number is found.
=IF((INT((ROWS(K$4:K4)-1)/2+1))<=$J$2,INDEX(A$4:A$278,SMALL(IF(ISNUMBER($H$4:$H$278),ROW($A$4:$A$278)-ROW($A$4)+1),(INT((ROWS(K$4:K4)-1)/2+1)))-1),"")
The red portion of the formula is generating a number series as 1;1;2;2;3;3... and so on as we require the data in that pattern. The blue portion is getting the row number in which number is found and than -1 will return a row above it. Here also you need to change the refrence of green portion which is full data and refrence in SMALL, ISNUMBER, ROW function. Copy this formula across row 5 till Q5.
4. In cell K6, I had below formula to get row of data in which you find the number. The logic is same as above formula but in this -1 is not there. Copy this across row 6 till Q6.
=IF((INT((ROWS(K$4:K4)-1)/2+1))<=$J$2,INDEX(A$5:A$278,SMALL(IF(ISNUMBER($H$5:$H$278),ROW($A$5:$A$278)-ROW($A$5)+1),(INT((ROWS(K$4:K4)-1)/2+1)))),"")
Now select Both K5:Q6 and drag till the end (@to the minimum of row twice of the count of result of formula 2).
Hope this will clear your doubts.
Advise if any issue.
Regards,