Your question is missing most of the necessary information, so I will make some assumptions:
- Column H - Your Total Sum
- You put this formula in H16
- Column G is in addition to your total.
- Column F is the deductions from your total
- Do you want to leave the summation cell empty if no debit or credit is entered
The answer will be as follows:
=IF(COUNTBLANK(F16:G16)<>2,H15+G16-F16,"")
COUNTBLANK indicates how many cells are full or set to "".
IF allows you to conditionally perform one of two actions, based on whether the first statement is true or false. The second argument, separated by a comma, is what should be done if it is true, the third argument, separated by a comma, is what should be done if it is false.
<> means not equal.
The equation says that if the number of empty cells in the range of F16:G16 (your credit and debit cells) is not 2, it means that both values ββare not empty, and then calculate the equation that you indicated in your question. Otherwise, the cell must be empty ( "" ).
When you copy this equation to new cells in column H other than H16 , it updates the row references to see the correct rows for credit and debit amounts.
CAVEAT: This equation is useful if you simply add entries for credits and debits to the end of the list and want the current total amount to be updated automatically. You fill this equation to some arbitrary long length and end the actual data. You would not see the current amount for the end of the credit / debit entries, then it would be empty until you filled out a new credit / debit entry. If you left an empty line in your credit debit entries, a link to the previous total amount of H15 would indicate an empty value, which in this case is treated as 0.
source share