# Modifying an Excel formula to count only visible cells, not all cells

I have two formulas below that count visible and non-visible cells. Need assistance so that they only count visible cells.
Thanks

="# of Factory Issues: "&COUNTIF(AG11:AG2011,"<>")

="Instances of 2016 Dates = "&COUNTIFS(L11:L2011,">="&\$AW\$2,L11:L2011,"<="&\$AW\$3)
(Column AW2 and AW3 contain 1/1/16 and 12/31/16)
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Hi, Is this what you are looking for?

This will count the values while you are using a filter

=SUBTOTAL(2,A2:A500)
Subtotal.xlsx
Commented:
In general, as per your other questions, when you want to count only visible cells with a condition or conditions you can invoke a SUMPRODUCT formula which includes your original conditions but also uses a SUBTOTAL(OFFSET construction to add an additional "visible" condition, so for the first formula:

="# of Factory Issues: "&SUMPRODUCT((AG11:AG2011<>"")+0,SUBTOTAL(3,OFFSET(AG11,ROW(AG11:AG2011)-ROW(AG11),0)))

....but in this specific example only, because the condition is "non-blank" and SUBTOTAL will only count non-blanks, the condition isn't required, SUBTOTAL alone should suffice, as per Wilder1626's suggestion, except you may need 3 as the first parameter of SUBTOTAL, i.e.

=SUBTOTAL(3,AG11:AG2011)

For the second formula there is no such shortcut - you need to use the full SUMPRODUCT version, i.e.

="Instances of 2016 Dates = "&SUMPRODUCT((L11:L2011>=\$AW\$2)*(L11:L2011<=\$AW\$3),SUBTOTAL(3,OFFSET(L11,ROW(L11:L2011)-ROW(L11),0)))

regards, barry

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
Works perfect! Thank you for your assistance and explanation
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.