Count Blanks in a Filtered Column

G

Gos-C

Hi,

Is there a function to count blanks in a filtered column? That is, i
I filter a column to show the rows that are blank, can I use th
subtotal function (or some other) to count the number of blanks?

Thanks,
Gos-
 
G

Guest

I couldn't find a direct way of doing that, but I think you may be able to
compute it:

Assuming your entire table is in A2:B7 and Column A of data contains some
sort of unique identifier (basically - it is a column that is guaranteed not
to be blank so that we can get a count of the total number of visible cells
after filtering) and Column B contains the data that may have blanks in it, I
believe you can use

=SUBTOTAL(3,A2:A7)-SUBTOTAL(3,B2:B7)

It seems that SUBTOTAL(3,B2:B7) will return a count of all items in column B
that are visible and NOT empty/blank. Therefore, subtracting this from the
total number of visible cells in Column A would give you the number of empty
cells in column B that are visible.
 
G

Guest

Alternatively, if all you need is the number of blank cells in a specified
column, don't bother w/filtering out the blank cells (as Gary said) - use his
formula or use COUNTBLANK function.
 
A

Aladin Akyurek

Assuming that the secret column range is B5:B200...

=SUMPRODUCT(SUBTOTAL(3,OFFSET(B5:B200,ROW(B5:B200)-ROW(B5)),,1)),--(B5:B200=""))
 
B

Biff

That doesn't work. Result = 0, unfiltered or filtered. I tried that formula
(along with many other variations) earlier.

Typo in the formula, one too many ")"

ROW(B5)),,1))

ROW(B5),,1))

Biff
 
B

Biff

Clarification:
That doesn't work.........

If the cells are EMPTY, it does work if the cells have formula BLANKS.

Don't know whether the OP meant "blank" or empty.

How would you count EMPTY cells? I haven't been able to figure it out.

Biff
 
G

Gos-C

Thanks, everyone, for your responses. I am very busy at work right no
so I will follow up later.

Gos-
 
B

Biff

Hi!

There is a huge difference between an empty cell and a blank cell.

The "problem" arises when people use the 2 terms interchangeably. An empty
cell is one that contains nothing, nothing at all. A blank cell can contain
a formula that returns "nothing" so the cell is not empty, it contains a
formula but the cell appears to be empty.

Try this:

Enter this FORMULA in A1: =""

Try these formulas:

=ISBLANK(A1)
=COUNTBLANK(A1)
=COUNTA(A1)
=LEN(A1)

2 of those formulas might lead you to believe that cell A1 is empty and the
other 2 "indicate" that something's there.

Biff
 
H

Harlan Grove

Biff wrote...
There is a huge difference between an empty cell and a blank cell.

So true.
The "problem" arises when people use the 2 terms interchangeably. An empty
cell is one that contains nothing, nothing at all. A blank cell can contain
a formula that returns "nothing" so the cell is not empty, it contains a
formula but the cell appears to be empty.

So wrong!

If X99 contained ="", does ISBLANK(X99) return TRUE or FALSE? If it
returns FALSE, why would you claim 'blank' means cells evaluating to
""?

In worksheet formulas, 'blank' has a precise meaning implied by the
ISBLANK function: the cell contains nothing. 'Empty' has no specified
meaning, so it's more naturally suited for use as meaning cells
containing zero length strings. Then there's the issue of cells
containing strings of nothing but one or more ASCII or HTML nonbreaking
spaces, which would also appear not to contain anything.
Try this:

Enter this FORMULA in A1: =""

And clear cell B1.
Try these formulas:

=ISBLANK(A1)

Indeed, do try this one. Then try

=ISBLANK(B1)
=COUNTBLANK(A1)

This is where Microsoft screwed up. It'll return 1, but so will

=COUNTBLANK(B1)
=COUNTA(A1)
=LEN(A1)

2 of those formulas might lead you to believe that cell A1 is empty and the
other 2 "indicate" that something's there.

ISBLANK and COUNTA are the reliable indicators. LEN is just doing it's
job. Since Excel converts blank cells (cells containing nothing) to ""
in string contexts, LEN correctly returns 0 when passed a reference to
a blank cell. It's COUNTBLANK that's flawed.

Definitions are everything sometimes. What do you mean by 'empty'?

Also, just because C uses ASCII NUL as a string terminator, so zero
length strings in C would be represented in memory as a single NUL
byte, doesn't mean Excel or any other software or programming language
follows that approach. Indeed, Perl and gawk are two examples of
programming languages closely related to C that don't use ASCIIZ
strings. Strings can be implemented as structures or classes containing
at minimum a length property and a pointer to allocated memory used to
store the string. Such strings could store anything, including several
NUL bytes.

There are 4 formulas here, so in B1:E1?
....

That the 5th and 6th rows are the same as the 1st after clearing A5 and
A6 should be no surprise. Clearing A5 and A6 makes those cells blank,
so they're the same as A1.

As for your 4th row, is the cell formatted as Text? Or are you
forgetting to mention an initial single quote? The numeric constant 0
should produce the same results as the formula =0, so B4:E4 should be
the same as B2:E2 rather than B3:E3.
 
H

Harlan Grove

Biff wrote...
....
How would you count EMPTY cells? I haven't been able to figure it out.
....

Presumably you mean cells containing nothing. If there were another
column in the filtered table that always contained something, then

=SUBTOTAL(3,OtherColumn)-SUBTOTAL(3,GivenColumn)

would count the number of cells in GivenColumn that contain nothing. As
for cells that contain things that evaluate to "", counting them
requires udfs.
 
B

Biff

=SUBTOTAL(3,OtherColumn)-SUBTOTAL(3,GivenColumn)

Doh!

Never even thought of that.
As for cells that contain things that evaluate to ""

Aladins formula seems to work for that. Lightly tested.

Biff
 
B

Biff

So wrong!
If X99 contained ="", does ISBLANK(X99) return TRUE or FALSE? If it
returns FALSE, why would you claim 'blank' means cells evaluating to
""?

What do mean "so wrong"?

Where did I claim blank means cells evaluating to ""?

That's why "nothing" is quoted!

Biff
 
H

Harlan Grove

Biff wrote...
....
Where did I claim blank means cells evaluating to ""?


That's why "nothing" is quoted!
....

You wrote: "The "problem" arises when people use the 2 terms
interchangeably. An empty cell is one that contains nothing, nothing at
all. A blank cell can contain a formula that returns "nothing" so the
cell is not empty, it contains a formula but the cell appears to be
empty."

You may have been imprecise in your definition of 'blank', but your
definition of 'empty' is the definition of 'blank' (in the ISBLANK
sense), so by stating that 'blank' means something else you're wrong.

Simple linguistics would imply most people would draw a correspondence
between 'blank' the state and ISBLANK the function. If so, 'blank'
means the state in which cells contain nothing (no quotes). Some other
term, perhaps 'empty', could be used to refer to cells with no visible
result (I tend to use 'visually blank').
 
B

Biff

you didn't read all of the posts : )

I did!

I didn't think of it, you did!

I thought about selecting all the EMPTY cells and padding them with a
formula blank.

I just thought that there might be a formula that didn't "depend" on another
column of data being present.

Biff
 
G

Guest

I did!
My apologies.
I just thought that there might be a formula that didn't "depend" on another
column of data being present.

Yeah, but darned if I can figure out how to identify an empty cell (while
weeding out those that are not visible due to a filter) using a more direct
approach. I was hoping someone else would figure it out. Maybe after the
blank cell versus empty cell issue is resolved? <g>
 
G

Guest

Maybe add a new column to the table and enter

=--(Cell("type", CellRef)="b")

and copy it down. Then use Subtotal(9, RangeRef) to get a count. Cell
seems to distinguish between truly empty cells and those that appear empty.
Interestingly, it seems Microsoft is also confused on the terminology.
According to help, the CELL function:

"Returns "b" for blank if the cell is empty"

Couldn't get it to work in an array formula, so it's still a two step process.
 
B

Biff

Subtotal(9, RangeRef)

I tried to "leverage" that approach based on the single column attempts.

My logic was an empty cell would have a sum of zero, then just count the
number of zero sums.

It failed!

Subtotal isn't a very "flexible" function, sort of like the Rank function,
you can only do so much with it.

Biff
 
A

Aladin Akyurek

Two points...

1) The suggestion I made has a paren too many at the wrong place.
2) More important: The Subtotal bit should take not the range subject to
counting, rather a range where the filter is applied.

=SUMPRODUCT(SUBTOTAL(3,OFFSET(A5:A200,ROW(A5:A200)-ROW(A5),,1)),--(B5:B200=""))

where A5:A200 is object of filtering and B5:B200 object of counting.

This would yield a count of empty cells and formula-blanks.

=SUMPRODUCT(SUBTOTAL(3,OFFSET(A5:A200,ROW(A5:A200)-ROW(A5),,1)),--ISBLANK(B5:B200=))

This would yield a count of empty cells only.

ISBLANK ignores cells created with formulas like ="".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top