How to Use COUNTIF for Nonoverlapping 40-Row Groups in Excel
Question details
The user needs a way to calculate COUNTIF for consecutive, non-overlapping groups of 40 rows without manually adjusting the formula.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- When analyzing data divided into consistent 40-row blocks, the user attempts to drag the COUNTIF formula down to auto-populate the results.
- Observed behavior
- Excel's standard autofill shifts the range down by exactly one row at a time (e.g., J2:J41 becomes J3:J42), resulting in overlapping ranges rather than consecutive 40-row jumps (J42:J81).
Verify that your target data is organized without blank spacer rows in the middle of your 40-row blocks, and locate an empty column where you will enter your counting formulas.
Use INDEX and ROW to Force Non-overlapping Ranges
Combine the INDEX and ROW functions to calculate the start and end of your range dynamically, effectively skipping 40 rows each time the formula is dragged down.
By default, Excel relative references change by exactly one row when dragged down. To make a formula jump by 40 rows automatically, we must mathematically define the range using the ROW function to create a multiplier, and use the INDEX function to translate that math into a valid cell reference.
Click on the cell where you want the very first calculation to appear (for example, row 2 in an empty column).
Type the following formula: =COUNTIF(INDEX(J:J,40*(ROW(A2)-ROW(A$2))+2):INDEX(J:J,40*(ROW(A2)-ROW(A$2))+41),"Yes"). Be sure to replace "Yes" with the actual criteria you are trying to count.
Press the Enter key. The cell will now display the count of your criteria specifically for the first block (cells J2 through J41).
Click the small square fill handle at the bottom right corner of the formula cell and drag it down. The subsequent cells will now calculate J42:J81, J82:J121, and so on without overlapping.

Easily Handle Complex Data Operations in WPS Spreadsheet
WPS Spreadsheet provides robust native support for advanced nested functions, allowing you to use INDEX, ROW, and COUNTIF together to manipulate datasets smoothly just as you would in Microsoft Excel.
- 1. Open your data file: Launch WPS Spreadsheet and open the .xlsx file containing your dataset.
- 2. Input the nested formula: Select the target cell, type the formula combining COUNTIF, INDEX, and ROW to define your 40-row block, and press Enter.
- 3. Drag to calculate: Use the smart fill handle in the lower right corner to drag the formula down, automatically generating your non-overlapping totals.

Frequently Asked Questions
Can I use the OFFSET function to create non-overlapping ranges?
Yes, you can use OFFSET like this: =COUNTIF(OFFSET($J$2, (ROW(A1)-1)*40, 0, 40), "Yes"). However, OFFSET is a volatile function that recalculates every time any change is made in the workbook, which can slow down performance on large datasets. The INDEX method is highly recommended for better speed.
How do I change the group size from 40 rows to 15 rows?
To change the block size, replace the '40' in the multiplier. For 15 rows, the formula's start calculation would be 15*(ROW(A2)-ROW(A$2))+2, and the end calculation would be +16. Simply ensure the difference between the starting and ending index numbers correctly reflects your desired range size.
Why does my autofill just copy the exact same numbers?
If autofill copies the same result, make sure Calculation Options in the Formulas tab is set to 'Automatic' rather than 'Manual'. If it is set to automatic, double-check your formula to ensure you did not accidentally lock the relative row references (e.g., using $A$2 instead of A2 inside the ROW function).
Can I use this same logic to SUM non-overlapping groups instead of counting them?
Absolutely. You can replace the COUNTIF function with SUM or SUMIF while leaving the INDEX(J:J...):INDEX(J:J...) range construction intact. This allows you to add up values in perfectly divided, non-overlapping chunks.




