The answer is to make "anchor cells" as references, from which you may calculate your offsets. Your first anchor in the given example is Test Sheet$A18. I normally make a designated range for that cell for my own convenience.
In my example here, you can see that cell A4 is named DataAnchor.
Your next anchor is the FIRST cell of your formula in relation to the anchor cell. (Clearly, if you move things around your relative "constants" will change. So be advised.)
In this example, my first cell with the formula is F8.
You compute: To determine the relative row offset between the anchor row and my formula row:
That's the current row number minus the row number of the anchor minus two.
Then the formula in F8 copied down becomes: