Search Contextures Sites ![]()
Count cells that match criteria -- COUNTIF
Count Rows in a Filtered List -- SUBTOTAL
After you filter the rows in a list, you can use the SUBTOTAL function to count the visible rows.
- Apply an AutoFilter to the table. There are instructions here -- AutoFilter Basics
- Filter at least one of the columns in the table. In this example, the first column has been filtered for Binders.
- Select the cell immediately below the column you want to sum.
- Click the AutoSum button on the Excel's Standard toolbar.
- If you want the SUBTOTAL function in a cell other than the one directly below the filtered list, you can type the formula, instead of using the AutoSum button.
- A SUBTOTAL formula will be automatically inserted, totalling the visible cells in the column
- The first argument in the SUBTOTAL function is a function number, that specifies how the numbers should be calculated. The default is 9, which tells Excel to SUM the numbers.
- Other function numbers can be used, such as 1 for AVERAGE, and 3 for COUNTA. Look in Excel's Help for a complete list.
- To Count all the non-empty cells in column D, use a 3 as the first argument:
=SUBTOTAL(3,D2:D10)
- Press the Enter key to complete the formula entry.
Note: In Excel 2003, you can use the formula:
=SUBTOTAL(103,D2:D10)
to subtotal rows which have been manually hidden, or filtered.
=SUBTOTAL(3,D2:D10)
Count Visible Items in a Filtered ListLaurent Longre created a formula that lets you work with visible rows after a filter. For information see, Power Formula Technique in this article at John Walkenbach's web site:
http://j-walk.com/ss/excel/eee/eee001.txtIncorporating that technique, SUMPRODUCT can be used to count visible items in a filtered table. In the following example, column D has been filtered for amounts greater than 100. The following formula will count the number of visible rows that contain "Pen" in column A.
- From the dropdown list in cell D1, select Custom.
- Filter for rows greater than 100.
- In cell A12, type: Pen
- In cell B12, enter the following formula:
![]()
=SUMPRODUCT(SUBTOTAL(3,OFFSET(A1:A10,ROW(A1:A10)
-MIN(ROW(A1:A10)),,1)), --(A1:A10=A12))
Worksheet Functions -- Sum Cells
Worksheet Functions -- VLOOKUP
Worksheet Functions -- INDEX / MATCH
Worksheet Functions -- Count Cells
Worksheet Functions -- INDIRECTVideo Tutorials:
Last updated: May 24, 2009 11:07 PM