To count the number of visible rows in a filtered list, you can use the SUBTOTAL function, which automatically ignores rows that are hidden by a filter. In the example shown, the formula in cell C2 is:
The SUBTOTAL function can perform calculations like COUNT, SUM, MAX, MIN, and more. What makes SUBTOTAL especially interesting and useful is that it automatically ignores items that are not visible in a filtered list or table. This makes it ideal for showing how many items are visible in a list, the subtotal of visible rows, etc.
Following the example in the image above, to count the number of non-blank rows visible when a filter is active, use:
The Excel SUBTOTAL function returns an aggregate result for supplied values. SUBTOTAL can return a SUM, AVERAGE, COUNT, MAX, and others (see table below), and SUBTOTAL function can either include or exclude values in hidden rows.
In this video, we show you how to add a message at the top of a filtered list that displays total and visible items in the list.
Excel Formula Training
Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.