Calculate difference between three cells

My spreadsheet has three columns (paydays) and a 4th that calculates (displays) the difference in between the budget amount and the three columns. So, E12 is the budget amt, G12,H12 and I12 are the paydays. Then in J12 is the difference (the formula below). This issue with this is, I only pay the bill on one of the three pay dates normally, so I have a formula that compares the amt in G, H and I. I set this up as this:

=IF(G12<>"",E12-G12,IF(H12<>"",E12-H12,IF(I12<>"",E12-I12,0)))

This works fine, however the MAIN issue is if I pay ‘extra’ on a bill in a later pay period, say cell H12 or I12 it’s not calculated into the difference due to the formula (or two cells in any order).

Any suggestions on how to modify the formula? Trying to avoid a million nested IF statements.

Thanks,

D

=IF(SUM(G12:I12)<>"";E12-SUM(G12:I12);0)


Add Answer is reserved for solutions.

Press edit below your question if you want to add more information; also can comment an answer.

Check the mark (Correct answer mark) to the left of the answer that solves your question.