Expanding on Kruug's answer, you can use the COUNTA function to test whether any data have been entered in the parts of the worksheet that you consider data entry areas.
For example, the following formulas would show a zero only if something was entered into the range A1:I11
of the worksheet you are interested in:
For cell G12: =IF(COUNTA(A1:I11)>0,SUM(D12,F12),"")
For cell I12 =IF(COUNTA(A1:I11)>0,SUM(F12,-G12),"")
The range you specify in the COUNTA function can be any range or groups of ranges that you want. For example, if you were concerned only with the cells directly above your two sums, then you could change the formulas to:
For cell G12: =IF(COUNTA(D1:D11,F1:F11)>0,SUM(D12,F12),"")
For cell I12 =IF(COUNTA(D1:D11,F1:F11)>0,SUM(F12,-G12),"")
(I'm showing the two ranges in the COUNTA function purely as an example, since I don't know what you would consider to be data ranges.)
The only thing you shouldn't do is test for data entry anywhere in the entire worksheet, because then the range to be counted would include your sum formulas and create a circular reference error.
SUM(D12+E12)
andSUM(F12-G12)
––D12+E12
andF12-G12
(respectively) are equivalent. Or, instead ofD12+E12
, you could saySUM(D12,E12)
orSUM(D12:E12)
. TheSUM
function is particularly handy for adding rows, columns, and even rectangular blocks of numbers (e.g.,SUM(A12:Z12)
,SUM(D1:D42)
, andSUM(D12:Q17)
); many Excel worksheet formula functions work similarly.