How to Count Five Consecutive Values Greater Than 40 in an Excel Row
Question details
The user needs to find a way to count how many times a sequence of five consecutive cells in a specific row contains values greater than 40.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Analyzing row data horizontally to calculate the number of specific consecutive numeric patterns or streaks.
- Observed behavior
- Requires a formula to accurately calculate overlapping sequences of five consecutive cells meeting a numeric condition (>40) horizontally.
Ensure your data is arranged horizontally in a single row without any merged cells, as merged cells can disrupt the alignment of ranges in your formula.
Use the SUMPRODUCT Formula with Offset Ranges
This method uses the SUMPRODUCT function to simultaneously compare five staggered, overlapping ranges within the same row.
By offsetting the start and end of the target range by one column for each condition, the SUMPRODUCT formula evaluates adjacent groups of five cells. If all five cells in a given group are greater than 40, the formula counts it as a valid instance.
Click on the empty cell where you want the final consecutive sequence count to appear.
Type the following formula: =SUMPRODUCT(--(ALL2:APC2>40),--(ALM2:APD2>40),--(ALN2:APE2>40),--(ALO2:APF2>40),--(ALP2:APG2>40)). Note how each subsequent range starts and ends exactly one column to the right.
Hit Enter on your keyboard. The cell will now display the total count of times five consecutive values exceed 40.

Easily Calculate Complex Array Formulas with WPS Office
WPS Spreadsheet fully supports advanced array functions like SUMPRODUCT, allowing you to analyze streaks, sequences, and consecutive data patterns seamlessly.
- 1. Open your dataset in WPS Spreadsheet: Launch WPS Office and open your .xlsx file containing the horizontal row data you want to analyze.
- 2. Input the array formula: Select your result cell and enter the overlapping SUMPRODUCT formula provided in the solution.
- 3. Get instant results: Press Enter to execute the calculation. WPS Spreadsheet handles complex multi-range evaluations instantly.

Frequently Asked Questions
How do I count non-overlapping consecutive values instead?
Counting strictly non-overlapping sequences requires a more complex array formula using FREQUENCY and IF, or utilizing a helper row to reset the count back to zero after reaching five consecutive matches.
Why does my SUMPRODUCT formula return a #VALUE! error?
Ensure that all the offset ranges inside your SUMPRODUCT formula are the exact same size (e.g., all spanning exactly the same number of columns). If one range is longer or shorter than the others, the formula will return a #VALUE! error.
Can I use this formula for columns instead of rows?
Yes, simply adjust the cell references to shift vertically (e.g., A2:A10, A3:A11) instead of horizontally (e.g., A2:H2, B2:I2). The logic of offsetting the range by one cell remains exactly the same.




