简体   繁体   中英

IF statement syntax in Excel

Basically what I'm trying to do is have the value in C7 shown if the cell isn't empty and if the the cell range C8:C16 contains only 0s. I'm using the code below but I can't get the syntax right

     =IF(NOT(ISBLANK(C7))),AND(IF(ISBLANK(C8:C16))),c7

=IF(AND(NOT(ISBLANK(C7)),COUNTIF(C8:C16,"0")=5),C7,)

您需要countif来检查多少个值为countif仅检查其中一个为0。

Assuming that the formula is being put in a cell other than C7 and C8:16, then you could use this:

=IF(AND(C7<>"",COUNTIF(C8:C16,0)=9),C7)

This will check if both C7 is not blank and C8:C16 contains 9 zeroes (hence all contain 0), and only when the two are true, it will return the value from C7.

The syntax for AND is:

AND(expr1, expr2, ...)

Where exprN is an expression that returns a boolean value (true/false or 1/0 )

In case C7 is blank and/or C8:C16 contains a non-zero value, the above will return FALSE . If you want something specific instead, then use something like this perhaps:

=IF(AND(C7<>"",COUNTIF(C8:C16,0)=9),C7,"return this sentence if false")

试试下面的公式

=IF(AND(SUM(C8:C16)=0,C7<>""),C7,"")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM