Home » excel » excel – if cell is not blank, then do IF statement

excel – if cell is not blank, then do IF statement

Posted by: admin March 9, 2020 Leave a comment

Questions:

I have this simple statement in excel. I compare two dates. If the date 2 is greater than or equal to date 1, then I show 1. If not, then I show 0.

However, I would like to apply this function only when the cells contains text:

IF(NOT(ISBLANK((Q2<=R2;"1";"0")))

That gives me an error – what am I doing wrong?

How to&Answers:

Your formula is wrong. You probably meant something like:

=IF(AND(NOT(ISBLANK(Q2));NOT(ISBLANK(R2)));IF(Q2<=R2;"1";"0");"")

Another equivalent:

=IF(NOT(OR(ISBLANK(Q2);ISBLANK(R2)));IF(Q2<=R2;"1";"0");"")

Or even shorter:

=IF(OR(ISBLANK(Q2);ISBLANK(R2));"";IF(Q2<=R2;"1";"0"))

OR EVEN SHORTER:

=IF(OR(ISBLANK(Q2);ISBLANK(R2));"";--(Q2<=R2))

Answer:

You need to use AND statement in your formula

=IF(AND(IF(NOT(ISBLANK(Q2));TRUE;FALSE);Q2<=R2);”1″;”0″)

And if both conditions are met, return 1.

You could also add more conditions in your AND statement.