Formula Errors

Count Visible Filtered Times from 7 PM to Midnight in Excel

Tauseeq MagsiTauseeq Magsi Nov 22, 2026 870 views

Question details

Count only visible filtered rows with times from 7 PM up to midnight.

Count Visible Filtered Times from 7 PM to Midnight in Excel
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.
Before you start

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.

Solution 1Recommended

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.

1
Filter the table

Select the table, choose Data > Filter, and apply the filters you need.

2
Enter the counting formula

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))

3
Adjust the ranges

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.

4
Check the result

Change a filter using a column's filter arrow and confirm that the count updates for the visible rows.

Use SUMPRODUCT and SUBTOTAL to count visible evening times
Manually hidden rows: SUBTOTAL function number 3 excludes filtered-out rows but can include manually hidden rows. Use 103 instead of 3 to exclude manually hidden rows as well.
Count filtered times in WPS Spreadsheets

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. 1. Open the workbook: Open WPS Spreadsheets and use Open to select your Excel workbook.
  2. 2. Apply a filter: Select the table and choose Data > Filter, then filter the rows as needed.
  3. 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. 4. Update the references: Replace the M and N references with your own nonblank visibility-check column and time column, keeping the ranges aligned.
Count matching times in visible filtered rowsOpen and edit Microsoft Excel XLSX filesUse familiar spreadsheet formulas and filters
microsoft office alternative - wps office

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.