Checking cells for 2 conditions

M

Mary Lancaster

Hi,
I hope someone can help me with this. I have four cells A1:A4. If all four
cells contain data or are blank then thats okay. But if 1, 2 or 3 cells
contain data then I want a warning that all cells must be blank or contain
data.

Thanks
Mary
 
P

Pete_UK

Try this:

=IF(AND(COUNTA(A1:A4)>0,COUNTA(A1:A4)<4),"Incorrect entries","")

Change the wording of "Incorrect entries" to whatever message you
would like.

Hope this helps.

Pete
 
T

T. Valko

One way.

You can use a formula like this in, say, B4:

=IF(OR(COUNTA(A1:A4)=4,COUNTBLANK(A1:A4)=4),"","All 4 cells must be either
filled or left empty")

Maybe give it a bold red font.
 
H

Harlan Grove

Mary Lancaster said:
I hope someone can help me with this. I have four cells A1:A4. If all four
cells contain data or are blank then thats okay. But if 1, 2 or 3 cells
contain data then I want a warning that all cells must be blank or contain
data.

More alternatives,

=IF(ABS(COUNTA(A1:A4)-2)<2,"A1:A4 partially filled","")

=IF(AND(COUNTIF(A1:A4,{"=";"<>"})<4),"A1:A4 partially filled","")
 

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