We will be migrating from Ask to Discourse on the first week of August, read the details here

 Ask Your Question

# Nested IF statement to check two cells

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 close merge delete

## 1 Answer

Sort by » oldest newest most voted

Hello,

try this

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


Hope that helps.

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")

( 2020-10-03 08:27:59 +0200 )edit

Thank you.

( 2020-10-03 14:42:54 +0200 )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.

( 2020-10-03 15:49:12 +0200 )edit

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

( 2020-10-03 15:59:08 +0200 )edit

## Stats

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

Seen: 87 times

Last updated: Oct 03 '20