Count Visible Filtered Times from 7 PM to Midnight in Excel
Question details
Count only visible filtered rows with times from 7 PM up to midnight.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A filtered table contains time values in N2:N11, and the user wants to count matching visible rows.
- Observed behavior
- The desired count includes visible rows with times at or after 7:00 PM and before midnight.
Apply a filter to the table and make sure the time cells contain numeric, time-only values rather than text. Choose a column that has a nonblank value in every data row, such as M2:M11, to check row visibility.
Use SUMPRODUCT and SUBTOTAL to count visible evening times
Use this formula when column N contains time-only values and column M is populated in every data row.
SUBTOTAL checks whether each row is visible, while SUMPRODUCT counts the rows that meet both time conditions. The interval includes 7:00 PM but excludes midnight, which Excel stores as 0:00.
Select the table, choose Data > Filter, and apply the filters you need.
Select a cell outside the filtered data, such as N13, and enter: =SUMPRODUCT(SUBTOTAL(3,OFFSET(M2,ROW(M2:M11)-ROW(M2),0,1)),--ISNUMBER(N2:N11),--(N2:N11>=TIME(19,0,0)),--(N2:N11<1))
Replace M2:M11 and N2:N11 with your visibility-check and time ranges. Keep both ranges the same height and starting on the same row; also change the M2 references in OFFSET and ROW.
Change a filter using a column's filter arrow and confirm that the count updates for the visible rows.

Count visible evening times in WPS Spreadsheets
Use the same SUMPRODUCT, SUBTOTAL, and OFFSET approach in WPS Spreadsheets to count filtered rows with times from 7 PM up to midnight.
- 1. Open the workbook: Open WPS Spreadsheets and use Open to select your Excel workbook.
- 2. Apply a filter: Select the table and choose Data > Filter, then filter the rows as needed.
- 3. Enter the formula: Select a cell outside the filtered range and enter: =SUMPRODUCT(SUBTOTAL(3,OFFSET(M2,ROW(M2:M11)-ROW(M2),0,1)),--ISNUMBER(N2:N11),--(N2:N11>=TIME(19,0,0)),--(N2:N11<1))
- 4. Update the references: Replace the M and N references with your own nonblank visibility-check column and time column, keeping the ranges aligned.

Frequently Asked Questions
Does the formula include midnight?
No. It includes 7:00 PM and times before midnight. A time displayed as 12:00 AM is stored as 0:00 and is not included in the evening interval.
Why does the visibility-check column need to be nonblank?
SUBTOTAL with function number 3 counts nonblank cells. If a visible row has a blank cell in the selected M range, that row will not be counted.
What if my cells contain both dates and times?
The formula expects time-only values below 1. For numeric date-time values, use a helper column with =MOD(N2,1), fill it down, and use that helper column as the time range in the counting formula.
How can I exclude rows I hid manually?
Change SUBTOTAL(3,...) to SUBTOTAL(103,...) in the formula. Function number 103 excludes manually hidden rows as well as filtered-out rows.




