Excel Formula to Restart Counting When a Cell is Greater Than Zero
Question details
The user needs to create a formula for a running count that tracks consecutive zero values and resets whenever a corresponding cell contains a number greater than zero.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Tracking consecutive zero values in a column and restarting the count upon encountering a value greater than zero.
- Observed behavior
- A running count increments for each consecutive zero value and resets to zero when the reference cell contains a positive number.
Ensure your data is organized in columns with a clear header row. Identify the column containing the values you want to evaluate (e.g., Column C) and the adjacent column where the running count will appear (e.g., Column D).
Use the IF and SUM Functions to Reset the Count
This method evaluates the current cell's value and increments the previous count if the value is zero, or resets it to zero if the value is greater than zero.
By combining the IF and SUM functions, you create a resilient formula that safely bypasses text headers and increments numbers accurately.
Select the cell where you want the running count to start (e.g., cell D2, assuming headers are in row 1).
Enter the formula =IF(C2=0,SUM(D1,1),0) into the formula bar. This checks if C2 is 0; if true, it adds 1 to the value above it in D1.
Press Enter to apply the formula, then click the fill handle at the bottom-right corner of cell D2 and drag it down to fill the formula through the rest of your data.

Use a Direct Addition IF Formula
An alternative approach that directly adds 1 to the previous cell, useful when your data setup ensures the cell above is strictly numeric.
Effortlessly Manage Running Counts and Complex Formulas with WPS Spreadsheet
WPS Spreadsheet provides robust support for all standard logical formulas, including IF, SUM, and nested functions, allowing you to easily track data and automate counting scenarios.
- 1. Install WPS Office: Download and install WPS Office, then launch WPS Spreadsheet.
- 2. Open Your Data: Open your existing Excel workbook or start a new spreadsheet for your counting tasks.
- 3. Apply the Formula: Select the target cell and enter the IF and SUM formula to track your zeroes.
- 4. Fill the Data: Drag the fill handle to apply the running count logic seamlessly across your dataset.

Frequently Asked Questions
Why does my D1+1 formula return a #VALUE! error?
If cell D1 contains a text header (like 'Count' or 'Total'), attempting to add 1 directly using the plus operator results in a #VALUE! error. Using SUM(D1,1) bypasses this issue because the SUM function ignores text.
How can I reset the count when a cell is any non-zero value, including negative numbers?
You can modify the logical test in your IF formula. Instead of C2>0, use C2<>0 to check if the cell is not equal to zero. The formula becomes =IF(C2<>0,0,SUM(D1,1)).
Can I restart the count at 1 instead of 0?
Yes, you can adjust the formula logic to start or reset at 1. Depending on your data structure, you might change the 'value_if_true' argument in the IF function from 0 to 1, such as =IF(C2>0,1,D1+1).
Does this formula work if there are blank cells in the reference column?
In Excel, blank cells are typically evaluated as zero in mathematical logical tests. If you want blank cells to be ignored or treated differently than zeroes, you should add a nested IF or use the ISBLANK function to handle them explicitly.




