I\'m really struggling to find an answer to this as online I\'ve really only found VBA solutions to this problem which isn\'t what I wish to learn how to do.
This does not use array formulas, but does use a helper column. Assuming data in cols A through D, in E2 enter:
=IF(A2="O",1+MAX($E$1:E1),"")
and copy down:
Each of the O rows is marked with a simple sequential value. This makes it easy for the usual MATCH() / INDEX() methods.
Pick some other cell and enter:
=IFERROR(INDEX(A:A,MATCH(ROWS($1:1),$E:$E,0)),"")
and copy this cell both across and down: