If a cell is not null, insert a formula into another cell

M

Michelle Hillard

Hi guys

I need to put a formula into a cell E2

=DATEDIF(B2,C2,"d")

but only activate this formula if B2 is not null.

If B2 is null, then E2 is null.


Any ideas greatly appreciated.

--


---------------------------------------------------------------------
"Are you still wasting your time with spam?...
There is a solution!"

Protected by GIANT Company's Spam Inspector
The most powerful anti-spam software available.
http://mail.spaminspector.com
 
N

Norman Harker

Hi Michelle!

Try:

=IF(B2="","",DATEDIF(B2,C2,"d"))

But if you wanted to get "" if either B2 or C2 is null then:

=IF(OR(B2="",C2=""),"",DATEDIF(B2,C2,"d"))

If B2 and C2 are mere date entries with no calculated or declared time
element then you can use C2-B2 instead of DATEDIF.

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
D

Dave Peterson

And just to add, you could use:

=C2-B2

(format as general, instead of the =datedif() formula.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top