I am trying to compose a function that compares the contents of two pairs of cells. If the contents match, I want excel to output the value C7-D7-'Ft & Hrs Surface'!H6. Otherwise, I would like excel to check the next pair of cells in the sheet (for example, if B6 and C6 were not a match, move on to B7 and C7) and continue iterating until a match is found. If there is no match available, I want the output to be simply C7-D7.

Although it is not completely encompassing for what i need, here is the "IF" statement I have composed thus far. I just need to somehow include the iteration part. Maybe some kind of loop?

=IF(AND(A7='Ft & Hrs Surface'!A6,B7='Ft & Hrs Surface'!B6),C7-D7-'Ft & Hrs Surface'!H6,C7-D7)

Anyone have any ideas?

Much Appreciated!