Here's and example using INDEX and a fixed reference to $A$1. The yellow filled row has the formula in all columns except column E.
Cells in column E contain RAND() which generates a pseudo random value between 0 and in each cell containg the function whenever there's a change in the table. he change in this case is a click on the checkbox cell in E1, toggling its value between true and false.
The table was sorted after each click on the checkbox (added after the first image was taken), and a screenshot taken if the sort resulted in a different position of the colour filled row.
The formula, shown below the last table copies the value from the cell above by creating a pair of index values pointing to that celll.
Original:
Sorted:
Empty cells (as seen in row 1) return a value of zero.
Third example (note that checkbox has been added in cell E1)
Fourth (and last) example:
Formula: (copied from cell A5 in table sorted as sorted in Fourth example.)
INDEX($A:$E,ROW()−1,COLUMN())
Regards,
Barry