Forum Discussion
Formula to Count only filtered columns but also doesnt count hidden cell formulas
You can use the “SUBTOTAL” function with the function number 109 to count only visible cells that contain any value, including text and logical values. The difference between using number 103 and 10` is that 103 counts only visible cells that contain numbers, while 109 counts all visible cells that contain any value. You can choice between 103 and 109.
For example, if you have a range of cells that contains numbers, text, and logical values, and you want to count only the visible cells that contain any value, you can use the formula =SUBTOTAL(109,A2:A10) .
I hope this clarifies the difference between using 103 and 109 with the SUBTOTAL function.
I hope this helps!
Subtotal works, but 109 is not the correct number for counting, it's for 'SUM'. 103 will perform 'COUNTA' on only visible cells.
- NikolinoDESep 30, 2024Gold Contributor
My earlier response needs clarification regarding the function numbers used in the SUBTOTAL formula. For counting non-empty visible cells (including formulas that might evaluate to blank), use SUBTOTAL(103, ...), where 103 performs the COUNTA operation, ignoring hidden rows but still counting cells with formulas, even if they appear blank.
To exclude hidden rows AND cells with formulas that evaluate to blank, ,maybe you can use the following workaround:
=SUMPRODUCT((SUBTOTAL(103, OFFSET(A2:A100, ROW(A2:A100)-ROW(A2), 0)) = 1) * (A2:A100 <> ""))