In D2 put this formula
=IF(LEN(C2),(C2-B2)/30,"")
Juan Pablo G.
You can try this... makes more sense for starters.
Write this formula in D2 --> =IF(C2="","",(C2-B2)/30)
Technically, you can't enter a formula into D2 and leave it blank...
By definition a blank cell is an empty cell, and
by their nature all functions return "something"
(a value). The recommendations below don't leave
cell D2 blank -- they return the null text string
value, "". The practice of mixing data types --
numeric and text -- in a given cell or column can
cause problems later when the cell is used in an
arithmetic expression. That's because =""+1 will
produce the #VALUE! error. I'd strongly recommend
that if C2 is blank you return a 0 in D2 [using
the formula, =IF(ISBLANK(C2),0,(C2-B2)/30)] and
then apply the custom format 0;-0 to D2 so the
zero won't be displayed -- in effect, making D2
"appear" blank.
Re: Technically, you can't enter a formula into D2 and leave it blank...
I agree if one consistently applies the rule of never returning a "" using a formula (I leave aside returning #N/A, e.g., by lookup functions). When this rule is in force, we can simplify the formula:
=IF(C2,(C2-B2)/30,0)
or depending on the intent:
=IF(AND(B2,C2),(C2-B2)/30,0)
If the rule is NOT in force, I'd be conservative and suggest (as Juan did)
=IF(LEN(C2),(C2-B2)/30,x)
or depending on the intent again:
=IF(AND(LEN(B2),LEN(C2)),(C2-B2)/30,x)
where x is either that dreaded "" or 0, continuing the "practice of mixing data types" in accordance what we know: people keep "mixing data types".
BTW: The LEN or ="" test survives a formula returned "", ISBLANK does not.
=========