I want to subtract two cells in excel but only if both cells have a value. More specifiaclly in my case the formula in cell C2 is currently =B2-A2
but I only want this to be calculated when B2 has a value or A2 has a value. I tried this formula
=IF(AND(B12<>"",A12<>""),B12-A12," ")
but after the 12th row, it started showing an error of #VALUE!
Best Answer
You can use the
ISBLANK
function:=IF(OR(ISBLANK(A2),ISBLANK(B2)),"",B2-A2)