简体   繁体   English

Excel countif公式两个条件

[英]Excel countif formula two conditions

I am having difficulties with the countif formula, because I need to count if a certain sheet has values that start with the number "2" but only if its length is equal to "9".我在使用 countif 公式时遇到困难,因为我需要计算某个工作表是否具有以数字“2”开头的值,但前提是其长度等于“9”。

在此处输入图片说明

=(COUNTIFS(sheet2_2019!A:A;"2*";sheet2_2019!A:A;SUMPRODUCT(N(LEN(sheet_2019!A:A)=9))))

The first part is easy, to see if the cell starts with "2" but the length I not figuring out how to do it.第一部分很容易,看看单元格是否以“2”开头,但长度我不知道如何去做。

Do you know how can I solve this?你知道我该如何解决这个问题吗?

Thanks谢谢

除了星号,您可以将问号通配符用作构成总共九个字符串的任何字符的占位符。: 2????????

=COUNTIFS(sheet2_2019!A:A,"2????????")

If you are working with numbers , perhaps like this:如果您正在使用numbers ,也许是这样的:

=COUNTIFS(sheet2_2019!A:A;">="&2*10^8;sheet2_2019!A:A;"<"&3*10^8)

This is based on the assumption that the underlying data is true numbers, and not values stored as text.这是基于以下假设:基础数据是真实数字,而不是存储为文本的值。

You cannot use COUNTIFS and use LEN() .您不能使用 COUNTIFS 并使用LEN() When needing to manipulate the data one will need to use an array type formula like SUMPRODUCT:当需要操作数据时,需要使用像 SUMPRODUCT 这样的数组类型公式:

=SUMPRODUCT((LEFT(sheet2_2019!A2:A4)="2")*(LEN(sheet2_2019!A2:A4)=9))

Being an array like formula, for best performance one must use the data range and not full column references.作为一个类似公式的数组,为了获得最佳性能,必须使用数据范围而不是完整的列引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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