Ask Your Question
1

Nested IF statement to check two cells

asked 2020-10-03 00:37:02 +0100

Bob Mc gravatar image

I need to check two cells in each row, and return "YES" if either have contents, or "NO" if both are empty. Have been trying nested IF statements using OR, but cannot seem to get it to return the correct statement. I know there are several ways of doing this, but think the IF function is probably the easiest.

Suggestions?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2020-10-03 02:44:41 +0100

igorlius gravatar image

updated 2020-10-03 15:57:17 +0100

Hello,

try this

=IF(AND(ISBLANK(A1);ISBLANK(B1));"NO";"YES")

Hope that helps.

edit flag offensive delete link more

Comments

2

if you like it nested:
=IF(A1<>"";"YES";IF(A2<>"";"YES";"NO")) or
=IF(A1="";IF(A2="";"NO";"YES");"YES"),
but 'grouping' arguments for results as @igorlius or
=IF(OR(A1<>"";A2<>"");"YES";"NO") is 'better',
if you ever write bigger 'programs', it makes a big difference in which thinking logic you approach each problem ...
several ways:
=IF(A1&A2<>"";"YES";"NO") or
=IF(A1&A2="";"NO";"YES")

newbie-02 gravatar imagenewbie-02 ( 2020-10-03 08:27:59 +0100 )edit

Thank you.

Bob Mc gravatar imageBob Mc ( 2020-10-03 14:42:54 +0100 )edit
1

@igorlius nitpick: please use the ; semicolon function parameter separator in examples, instead of the , comma separator. Reason is that independent of the localized separator configuration the semicolon is always accepted. Thanks.

erAck gravatar imageerAck ( 2020-10-03 15:49:12 +0100 )edit

@erAck, Sound reasoning. I'll try to keep it in mind from now on. Thanks.

igorlius gravatar imageigorlius ( 2020-10-03 15:59:08 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-10-03 00:37:02 +0100

Seen: 61 times

Last updated: Oct 03 '20