I want to use COUNTIF
in Excel, but I want to count rows where column V = yes OR column U = yes
, with all the other criteria the same.
It is easy to use or
with values in 1 column, such as P4:P999 = "apple" or "orange"
, but how to use or
over multiple columns?
Below is an Excel code sample written to be readable. The only solution I found was to use addition and rewrite the entire code, but I hate this solution because it is too long.
SUM(COUNTIFS(
P4:P9999, {"apple", "orange"},
B4:B9999, "potato",
AF4:AF9999, "",
V4:V9999, "Yes"
)
) +
SUM(COUNTIFS(
P4:P9999, {"apple", "orange"},
B4:B9999, "potato",
AF4:AF9999, "",
U4:U9999, "Yes"
)
)
切换到 SUMPRODUCT:
=SUMPRODUCT(((P4:P9999 = "apple")+(P4:P9999 = "orange"))*(B4:B999="potato")*(LEN(AF4:AF999)=0)*((V4:V9999="Yes)+(U4:U9999="Yes")>0))
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.