Home » excel » excel – How to count cells in a table column that contains a specific text string (COUNT.IF doesn't work)

# excel – How to count cells in a table column that contains a specific text string (COUNT.IF doesn't work)

Questions:

I need to count how many cells in a table column that contains a specific text string. I’m using this formula and it works well:

`=COUNT.IF(TB_table_name[col_name];"*string_to_be_found*")`

But I need to count only filtered cells.
I’ve found may solutions (using SUMPRODUCT) on internet, but only to common cells and not table conlumns.

This is the kind of table that I have:

As you can see, there are many values in the same cell (It happens because it is generated automatically by a survey made in MS Forms). Because of this, I need to search for a specific string to be counted.

Using “COUNT.IF” I have this results:

Please observe that the values in the cell are not random, but predefined – of course the sequence could not be the same, but the list of possible terms are.

Please, can you help me figure this out? Belive me, I have tried many things but nothing worked and it seems to be a thing so easy to achieve 🙁

The trick is to combine a couple of the ideas you found using `SUMPRODUCT`.

You likely found this reference (or one just like it) that gave guidance for a formula like this:

``````=SUMPRODUCT(SUBTOTAL(3,OFFSET(B2:B7,ROW(B2:B7)-MIN(ROW(B2:B7)),,1))*(B2:B7="Quality"))
``````

Which translates to your problem-space like this:

``````=SUMPRODUCT(SUBTOTAL(3,OFFSET(TB_table_name[col_name],ROW(TB_table_name[col_name])-MIN(ROW(TB_table_name[col_name])),,1))*(TB_table_name[col_name]="*string_to_be_found*"))
``````

This works perfectly fine if you’re NOT using a wildcard search. But that’s what you need. So in this answer it shows that the wildcard in a `SUMPRODUCT` needs to use the `--` operator. So the result is to combine the two answers and you get:

``````=SUMPRODUCT(SUBTOTAL(3,OFFSET(TB_table_name[col_name],ROW(TB_table_name[col_name])-MIN(ROW(TB_table_name[col_name])),,1))*(--(ISNUMBER(FIND("string_to_be_found",TB_table_name[col_name])))))
``````

Notice that the `string_to_be_found` does NOT have wildcard `*` specifiers. That’s taken care of by the `FIND` function.