Excel Countif Not equal to string length of zero

I have an iferror formula that is placed in "if an error occurs. This is a string with zero length. I would like to make an account if it is not equal to" ".

=countif(A:A,<>"") 'is not a valid formulas
=countif(A:A,"<>") 'checks for actual blanks, not zero length strings
+4
source share
3 answers

Count for empty cells using:

=COUNTBLANK(A2:B5)

and subtract this value from the total.

+4
source

Instead of using COUNTBLANKand subtracting from the total, you can use:

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

?- single character pattern.
*- a wildcard with multiple characters.
Combining these two, it will be counted if there are 1 or more characters.

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

+8

SUMPRODUCT, .

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

LEN(A:A)<>0checks the length of strings in a range A:Afor whether they are 0 or not. Wrap it in parens and put --it before it converts Trueto 1 and Falseto 0.

SUMPRODUCT then takes all 1s and 0s and adds them.

+6
source

Source: https://habr.com/ru/post/1540885/


All Articles