'Count rows that meet the criteria in a google sheet

I have created a google sheet table (A-AB) with the following organization:

https://docs.google.com/spreadsheets/d/1mggRbzANQQwAtf34rWLlNLP-AGrEQTmf2C-nxatP1Kw/edit?usp=sharing

enter image description here

A search function that highlights the rows based on this formula works like a charm:

=AND( 
    OR($F$1="Any",countif($C4:$F4,$F$1)>0),1,
    OR($H$1="Any",countif($G4:$H4,$H$1)>0),1,
    OR($J$1="Any",countif($I4:$J4,$J$1)>0),1,
    OR($L$1="Any",countif($K4:$AB4,$L$1)>0),1,
    OR($N$1="Any",countif($K4:$AB4,$N$1)>0),1
)

Additionally, I've got a field that should show the number of results highlighted. That's where the issue is happening. I've tried using a simple COUNTIF but I get a result of 0. My best guess is that I'm using the wrong function.

=COUNTIF (C3:AB333, 
    AND( 
        OR($F$1="Any",countif($C4:$F4,$F$1)>0),1,
        OR($H$1="Any",countif($G4:$H4,$H$1)>0),1,
        OR($J$1="Any",countif($I4:$J4,$J$1)>0),1,
        OR($L$1="Any",countif($K4:$AB4,$L$1)>0),1,
        OR($N$1="Any",countif($K4:$AB4,$N$1)>0),1
    )
)

Any help would be appreciated, thank you.



Solution 1:[1]

I've spent so much time searching for the answer and did not find the fitting one.

I've managed to bypass the issue by creating an additional column AC which basically contains TRUE/empty where the conditions are met and with a simple countif on values TRUE in that column, the counter is working.

The question will still be open for a better answer because this is a continuous project.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Djisin