How to Create a Running Count by Type in Excel Using COUNTIF
Question details
The user wants to generate an automatic running count (occurrence number) for repeated values in a specific column using an Excel formula.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Tracking data, occurrences, or inventory where items of the same type appear multiple times and require a sequential count next to them.
- Observed behavior
- Requires a dynamic formula that increments the count of a specific type as new data is added down the column, without needing manual updates.
Ensure your data is organized in clear columns without merged cells. Identify the specific column where your 'Type' values are located (e.g., Column D) before entering your formula.
Use the COUNTIF Function with an Expanding Range
The most efficient way to create a running count is by using an expanding range reference inside the COUNTIF function.
By anchoring the first row of your range and leaving the second row relative, the formula range expands as you drag it down. This allows Excel to count how many times a specific value has appeared from the top of the data set up to the current row.
Click on the cell in the first data row of your 'Type #' or 'Count' column (e.g., E2) where you want the running count to appear.
Assuming your type values start in cell D2, type the formula: =COUNTIF(D$2:D2, D2).
Press Enter to apply the formula. Then, click the fill handle (the small square at the bottom-right corner of the selected cell) and drag it down the column to apply the count to the remaining rows.

Calculate Running Counts Effortlessly in WPS Spreadsheet
WPS Office offers a powerful Spreadsheet application fully compatible with Excel formulas, including COUNTIF and expanding range references. You can organize data, calculate running counts, and analyze information completely for free.
- 1. Open your file in WPS: Launch WPS Office and open your spreadsheet file.
- 2. Input the formula: Select the cell next to your first item, and type =COUNTIF(D$2:D2, D2).
- 3. Drag to fill: Double-click or drag the fill handle at the bottom right corner of the cell to apply the formula down the column.
- 4. Review results: WPS Spreadsheet will instantly output the precise running count for each item type.

Frequently Asked Questions
Why is my running count formula returning 0 or giving errors?
Ensure that the criteria cell reference matches the exact text or number in your target column without extra leading or trailing spaces. Additionally, check that your formula uses a comma or semicolon correctly, as this depends on your operating system's regional settings.
Can I use COUNTIFS to do a running count based on multiple conditions?
Yes, you can use the COUNTIFS function to add more criteria. For example, =COUNTIFS(D$2:D2, D2, C$2:C2, "Completed") will give a running count of a specific type only if the status in column C is marked as 'Completed'.
How do I restart the running count if the list is sorted differently?
The expanding range COUNTIF formula relies on the physical top-to-bottom order of the rows. If you re-sort the data, the expanding range (e.g., D$2:D20) will automatically recalculate the running occurrence based on the new visual order.
Why does the formula use a dollar sign ($) only for the row number?
The dollar sign ($) creates an absolute reference. Writing D$2 locks row 2 so the counting range always starts from the top. Leaving the second reference as D2 (without dollar signs) creates a relative reference, allowing the bottom of the range to move down as you copy the formula to lower rows.




