Hello,

You will need to change the reference to match each other. Here is your formula
=($C2-INDEX($C2:$C$3160,MATCH(D2,E3:E$3160,0),1))

Here is what it should have been
=($C2-INDEX($C3:$C$3160,MATCH(D2,E3:E$3160,0),1))

Previously your formula is returning the cell in the row above where a match is found.