Excel Countif Not equal to string length of zero

你。 提交于 2019-12-10 03:06:01

问题


I have a formula an iferror formula that puts in "" if an error occurs. This is a zero length string. I'd like to do a count if not equal to "".

=countif(A:A,<>"") 'is not a valid formulas
=countif(A:A,"<>") 'checks for actual blanks, not zero length strings

回答1:


Do a count for empty cells using:

=COUNTBLANK(A2:B5)

and subtract that value from the total.




回答2:


Rather than using COUNTBLANK and subtracting from the total, you can use:

=COUNTIF(A:A,"?*")

? is the single character wildcard.
* is the multiple character wildcard.
Combining these two, it will count if there are 1 or more characters.

Note that this works only if the cells contains strings, not numbers.




回答3:


You could perhaps use SUMPRODUCT since you have limited control over the range or criteria.

=SUMPRODUCT(--(LEN(A:A)<>0))

LEN(A:A)<>0 checks the length of the strings in the range A:A for whether they are 0 or not. Wrapping it in parens and putting -- before it will convert True to 1 and False to 0.

SUMPRODUCT then takes all the 1s and 0s and add them up.



来源:https://stackoverflow.com/questions/23701470/excel-countif-not-equal-to-string-length-of-zero

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!